I was wondering if it was possible in c# to do:
public class Outer
{
public class Inner {}
public Inner CreateInner()
{
return new Inner(); // should only be allowed inside this method
}
}
where you can only create a new instance of the Inner class inside an Outer class method. I want to do this because I need better control over what Inner class is created and it helps me mock the return value of CreateInner and verify that it was called. Is this possible?