protected override void Configure() { Container.Singleton <IEventAggregator, EventAggregator>(); Container.Singleton <IWindowManager, WindowManager>(); Container.PerRequest <IUnitOfWork, UnitOfWork>(); Container.RegisterHandler(typeof(IMediator), null, GetMediator); Container.RegisterHandler(typeof(PeopleContext), null, GetPeopleContext); }
protected override void Configure() { Container.Singleton <IWindowManager, WindowManager>(); Container.Singleton <IEventAggregator, EventAggregator>(); Container.PerRequest <ShellViewModel>(); Container.PerRequest <RemoteHelper>(); Container.PerRequest <MessageViewModel>(); Container.RegisterHandler(typeof(ICourseService), null, CreateCourseService); Container.RegisterHandler(typeof(IStudentService), null, CreateStudentService); Container.RegisterHandler(typeof(ITeacherService), null, CreateTeacherService); }
protected override void Configure() { ConfigureCaliburnConventions(); _container = new SimpleContainer(); _container.Singleton <IWindowManager, MahappsWindowManager>(); _container.Singleton <IEventAggregator, EventAggregator>(); _container.Singleton <IConfigurationService, ConfigurationService>(); _container.Singleton <IApplicationService, ApplicationService>(); _container.Singleton <IDialogManager, MaterialDesignDialogManager>(); _container.Singleton <LayoutManager>(); _container.PerRequest <IInterTabClient, CaliburnInterTabClient>(); _container.PerRequest <IInterLayoutClient, CaliburnInterLayoutClient>(); _container.PerRequest <IShell, ShellViewModel>(); _container.RegisterHandler(typeof(ILayoutManager), null, (_) => _container.GetInstance <LayoutManager>()); _container.RegisterHandler(typeof(ISnackbarMessageQueue), null, (_) => new SnackbarMessageQueue(TimeSpan.FromMilliseconds(5000))); var mapperConfig = ConfigureAutoMapper(_container); _container.RegisterInstance(typeof(IMapper), null, mapperConfig.CreateMapper()); _container.PerRequest <NewViewModel>(); _container.PerRequest <MenuViewModel>(); _container.PerRequest <Test1ViewModel>(); _container.PerRequest <Test2ViewModel>(); _container.PerRequest <ShellViewModel>(); _container.PerRequest <RenameViewModel>(); _container.PerRequest <SettingsViewModel>(); _container.PerRequest <EditUsersViewModel>(); _container.PerRequest <MessageBoxViewModel>(); #if DEBUG mapperConfig.AssertConfigurationIsValid(); //checks if MapperConfiguration is valid #endif ////log everything //LogManager.GetLog = t => new DebugLog(t); //log only messages of ViewLocator var baseGetLog = LogManager.GetLog; LogManager.GetLog = t => t == typeof(ViewLocator) ? new DebugLog(t) : baseGetLog(t); }
protected override void Configure() { _container.Singleton <IWindowManager, WindowManager>(); _container.PerRequest <ITaskExecutor <Bitmap>, TaskExecutor <Bitmap> >(); _container.PerRequest <ITaskExecutor <ImageProcessingOutput>, TaskExecutor <ImageProcessingOutput> >(); _container.RegisterSingleton(typeof(IImageProcessing), "sync", typeof(SynchronzousImageProcessing)); _container.RegisterSingleton(typeof(IImageProcessing), "async", typeof(AsynchronousImageProcessing)); _container.RegisterHandler(typeof(IImageProcessingStrategy), null, container => { var sync = IoC.Get <IImageProcessing>("sync"); var async = IoC.Get <IImageProcessing>("async"); return(new ImageProcessingStrategy(sync, async)); }); _container.PerRequest <IFileChooser, ImageFilesChooser>(); _container.Singleton <MainViewModel>(); }
protected override void Configure() { container = new SimpleContainer(); container.Singleton <IEventAggregator, EventAggregator>(); container.Singleton <IWindowManager, MetroWindowManager>(); container.Singleton <ITwitchTvV5ReadonlyClient, TwitchTvV5ReadonlyClient>(); container.Singleton <ITwitchTvHelixReadonlyClient, TwitchTvHelixHelixReadonlyClient>(); container.Singleton <IMonitoredStreamsFileHandler, MonitoredStreamsFileHandler>(); container.Singleton <ISettingsHandler, SettingsHandler>(); container.Singleton <IApiClientFactory, ApiClientFactory>(); container.Singleton <FilterModel>(); container.Singleton <INotificationHandler, NotificationHandler>(); // needs to be a single instance so we can add notifications from anywhere container.Singleton <PopularLivestreamWatcher>(); container.Singleton <StreamLauncher>(); container.PerRequest <ShellViewModel>(); container.PerRequest <ThemeSelectorViewModel>(); container.PerRequest <HeaderViewModel>(); container.PerRequest <MainViewModel>(); container.PerRequest <SettingsViewModel>(); container.PerRequest <LivestreamListViewModel>(); container.PerRequest <TopStreamsViewModel>(); container.PerRequest <VodListViewModel>(); container.PerRequest <ApiClientsQualitiesViewModel>(); // singleton instance of the navigation service - this relies on using the container so it needs special registration Core.INavigationService navigationService = null; container.RegisterHandler(typeof(Core.INavigationService), null, simpleContainer => navigationService ?? (navigationService = new NavigationService( simpleContainer, simpleContainer.GetInstance <IEventAggregator>()) )); #if FAKE_DATA // comment out the define at the top of this file to launch debug mode with real data container.Singleton <IMonitorStreamsModel, FakeMonitorStreamsModel>(); #else container.Singleton <IMonitorStreamsModel, MonitorStreamsModel>(); #endif }
public void RegisterHandler(Type service, Func <IInjectionContainer, object> handler, string key) => container.RegisterHandler(service, key, (container) => handler(this));
/// <summary> /// Registers a custom service handler with the container. /// </summary> /// <typeparam name="TService">The type of the service.</typeparam> /// <param name="container">The container.</param> /// <param name="handler">The handler.</param> /// <returns>The container.</returns> public static SimpleContainer Handler <TService>(this SimpleContainer container, Func <SimpleContainer, object> handler) { container.RegisterHandler(typeof(TService), null, handler); return(container); }