Код: Выделить всё
public class ViewPage : Page
where TView : IView
where TPresenter : Presenter
{
public ViewPage()
{
if (!(this is TView))
throw new Exception(String.Format("The view must be of type {0}", typeof(TView)));
IWindsorContainer container = new WindsorContainer();
container.AddComponent("view", typeof(IView), typeof(TView));
container.AddComponent("presenter", typeof(Presenter), typeof(TPresenter));
TPresenter presenter = container[typeof(TPresenter)] as TPresenter;
}
}
< /code>
И это код докладчика: < /p>
public class Presenter where T : IView
{
public T View { get; private set; }
public Presenter(T view)
{
this.View = view;
}
}
Как я могу это добиться? Спасибо.
Подробнее здесь: https://stackoverflow.com/questions/145 ... -of-a-type