public class MyClass
{
public static NestedClass<T> New<T>(Func<T> func)
{
return new NestedClassCreator<T>(func);
}
public class NestedClass<T>
{
private Func<T> _func;
protected NestedClass(Func<T> func)
{
_func = func;
}
}
private sealed class NestedClassCreator<T> : NestedClass<T>
{
public NestedClassCreator(Func<T> func)
: base(func)
{
}
}
}
public class MyClass
{
public static INestedClass<T> New<T>(Func<T> func)
{
return new NestedClass<T>(func);
}
public interface INestedClass<T>
{
}
private class NestedClass<T> : INestedClass<T>
{
private Func<T> _func;
public NestedClass(Func<T> func)
{
_func = func;
}
}
}
В последнем случае во внешнем коде соотв. пишете MyClass.INestedClass = MyClass.New(....);