namespace EveOPreview { public class ApplicationController : IApplicationController { private readonly IIocContainer _container; public ApplicationController(IIocContainer container) { this._container = container; this._container.RegisterInstance(this); } public IApplicationController RegisterView() where TView : IView where TImplementation : class, TView { this._container.Register(); return this; } public IApplicationController RegisterInstance(TArgument instance) { this._container.RegisterInstance(instance); return this; } public IApplicationController RegisterService() where TImplementation : class, TService { this._container.Register(); return this; } public void Run() where TPresenter : class, IPresenter { if (!this._container.IsRegistered()) { this._container.Register(); } TPresenter presenter = this._container.Resolve(); presenter.Run(); } public void Run(TParameter args) where TPresenter : class, IPresenter { if (!this._container.IsRegistered()) { this._container.Register(); } TPresenter presenter = this._container.Resolve(); presenter.Run(args); } public TService Create() where TService : class { if (!this._container.IsRegistered()) { this._container.Register(); } return this._container.Resolve(); } } }