Example #1
0
 protected override void Configure()
 {
     container = new SimpleContainer();
     container.RegisterSingleton(typeof(EventAggregator), null, typeof(EventAggregator));
     container.RegisterSingleton(typeof(IWindowManager), null, typeof(WindowManager));
     container.RegisterSingleton(typeof(MainWindowViewModel), null, typeof(MainWindowViewModel));
 }
Example #2
0
        protected override void Configure()
        {
            _container.RegisterSingleton(typeof(IWindowManager), null, typeof(WindowManager));
            _container.RegisterSingleton(typeof(ICustomerService), null, typeof(CustomerService));
            _container.RegisterSingleton(typeof(IShellViewModel), null, typeof(ShellViewModel));

            base.Configure();
        }
Example #3
0
        public static void Initialize()
        {
            IoC.GetInstance     = GetInstance;
            IoC.GetAllInstances = GetAllInstances;
            IoC.BuildUp         = BuildUp;

            Container.RegisterSingleton <IGameServer, GameServer>();
            Container.RegisterSingleton <IGameMessenger, GameMessenger>();
        }
 public static SimpleContainer AllSingletonTypesOf <TService>(this SimpleContainer container,
                                                              Assembly assembly        = null,
                                                              Func <Type, bool> filter = null)
 {
     return(AllTypesOf <TService>(container, type =>
     {
         container.RegisterSingleton(typeof(TService), null, type);
         container.RegisterSingleton(type, null, type);
     }, assembly, filter));
 }
Example #5
0
        protected override void Configure()
        {
            _container = new SimpleContainer();

            _container.RegisterSingleton(typeof(LoginViewModel), "loginViewModel", typeof(LoginViewModel));
            _container.RegisterSingleton(typeof(ServersViewModel), "serversViewModel", typeof(ServersViewModel));
            _container.RegisterSingleton(typeof(ShellViewModel), "shellViewModel", typeof(ShellViewModel));

            _container.RegisterInstance(typeof(ILog), "Logger", new DebugLogger(LogManager.GetLog.GetType()));
            _container.RegisterInstance(typeof(IWindowManager), "WindowManager", new WindowManager());
        }
Example #6
0
        protected override void Configure()
        {
            _container.Instance(_container);
            _container.Singleton <IWindowManager, WindowManager>();
            _container.Singleton <IEventAggregator, EventAggregator>();
            _container.RegisterInstance(typeof(IVideoRepository), "videorepository", new JsonVideoRepository(DataPath));

            _container.RegisterSingleton(typeof(MainViewModel), "main", typeof(MainViewModel));
            _container.RegisterSingleton(typeof(FilterControlViewModel), "filter", typeof(FilterControlViewModel));
            _container.RegisterSingleton(typeof(ListControlViewModel), "list", typeof(ListControlViewModel));
            _container.RegisterSingleton(typeof(ViewControlViewModel), "view", typeof(ViewControlViewModel));
        }
Example #7
0
        protected override void Configure()
        {
            container = new SimpleContainer();

            container.Singleton <IWindowManager, WindowManager>();
            container.RegisterSingleton
                (typeof(IUserNotificationProvider),
                "UserNotificationService",
                typeof(UserNotificationProvider));
            container.RegisterSingleton(typeof(CustomMessageBoxViewModel), "CustomMessageBoxViewModel", typeof(CustomMessageBoxViewModel));

            container.PerRequest <ShellViewModel>();
        }
Example #8
0
        public App()
        {
            //Note: Explicitly creating the container.
            var container = new SimpleContainer();

            CaliburnFramework
                .ConfigureCore(container) //Note: Setting the container.
                .WithPresentationFramework()
                .Start();

            //Note: Registering commands by key.
            container.RegisterSingleton<ShowMessageCommand>("ShowMessage");
            container.RegisterSingleton<ShowTitledMessageCommand>("ShowTitledMessage");
        }
Example #9
0
        private void ConfigureSimpleContainer()
        {
            _container = new SimpleContainer();

            _container.Singleton <IWindowManager, WindowManager>();
            _container.Singleton <IEventAggregator, EventAggregator>();

            _container.PerRequest <EmployeeContext, EmployeeContext>();
            _container.PerRequest <IEmployeeUnitOfWork, EmployeeUnitOfWork>();
            _container.PerRequest <EmployeeRepository, EmployeeRepository>();
            _container.PerRequest <UserGroupRepository, UserGroupRepository>();
            _container.PerRequest <UserRepository, UserRepository>();
            _container.PerRequest <PermissionKeyRepository, PermissionKeyRepository>();
            _container.PerRequest <UserGroupPermissionRepository, UserGroupPermissionRepository>();

            //_container.PerRequest<DialogViewModel, DialogViewModel>();
            //_container.AllTypesOf<IScreen>(Assembly.GetAssembly(typeof (EmployeeInfoViewModel)));

            _container.PerRequest <ILoginViewModel, LoginViewModel>();
            _container.RegisterSingleton(typeof(IShellViewModel), "ShellViewModel", typeof(ShellViewModel));
            var shellViewModel = _container.GetInstance(typeof(IShellViewModel), "ShellViewModel");

            _container.RegisterInstance(typeof(IProgressBarService), "ProgressBarService", shellViewModel);

            _container.PerRequest <IEmployeeInfoViewModel, EmployeeInfoViewModel>();
            _container.PerRequest <IAdministrationWorkspaceViewModel, AdministrationWorkspaceViewModel>();
            _container.PerRequest <IUserViewModel, UserViewModel>();
            _container.PerRequest <IUserGroupWorkspaceViewModel, UserGroupWorkspaceViewModel>();
            _container.PerRequest <IUserGroupViewModel, UserGroupViewModel>();
        }
Example #10
0
        /// <summary>
        /// 注册ViewModel
        /// </summary>
        /// <param name="_container"></param>
        public static void RegistInstances(this SimpleContainer container, Assembly asm)
        {
            var types = asm.DefinedTypes
                        .Select(t => {
                var attr = t.GetCustomAttribute <RegistAttribute>();
                return(new {
                    T = t,
                    Mode = attr?.Mode,
                    TargetType = attr?.ForType
                });
            })
                        .Where(o => o.Mode != null && o.Mode != InstanceMode.None);

            foreach (var t in types)
            {
                var type = t.T.AsType();
                if (t.Mode == InstanceMode.Singleton)
                {
                    container.RegisterSingleton(t.TargetType ?? type, null, type);
                }
                else if (t.Mode == InstanceMode.PreRequest)
                {
                    container.RegisterPerRequest(t.TargetType ?? type, null, type);
                }
            }
        }
Example #11
0
 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>();
 }
Example #12
0
        private void RegistModel(SimpleContainer container)
        {
            var types = this.GetType().GetTypeInfo().Assembly.DefinedTypes
                        .Select(t => new { T = t, Mode = t.GetCustomAttribute <RegistAttribute>()?.Mode })
                        .Where(o => o.Mode != null && o.Mode != InstanceMode.None);

            foreach (var t in types)
            {
                var type = t.T.AsType();
                if (t.Mode == InstanceMode.Singleton)
                {
                    container.RegisterSingleton(type, null, type);
                }
                else if (t.Mode == InstanceMode.PreRequest)
                {
                    container.RegisterPerRequest(type, null, type);
                }
            }

            //container
            //    .Singleton<TabViewModel>()
            //    .Singleton<SettingViewModel>()
            //    .Singleton<MDIViewModel>()
            //    .Singleton<IndexViewModel>()
            //    .Singleton<SearchViewModel>()
            //    .Singleton<CompanyPositionsViewModel>()
            //    .Singleton<MyViewModel>()
            //    .Singleton<LoginViewModel>()
            //    .Singleton<FavoritesViewModel>()

            //    .PerRequest<CitySelectorViewModel>()
            //    .PerRequest<JobDetailViewModel>()
            //    .PerRequest<SearchedItemViewModel>()
            //    ;
        }
        protected override void Configure()
        {
            _container = new SimpleContainer();
            IoC.Initialize(_container);

            _container.RegisterSingleton<IWindowManager, WindowManager>();
            _container.RegisterSingleton<IEventAggregator, EventAggregator>();
            _container.RegisterSingleton<IViewModelLocator, ViewModelLocator>();
            _container.RegisterSingleton<IViewModelBinder, ViewModelBinder>();

            var typeResolver = new ViewModelTypeResolver();
            typeResolver.AddMapping<ShellView, ShellViewModel>();
            _container.RegisterInstance<IViewModelTypeResolver>(typeResolver);
            
            _container.RegisterPerRequest<ShellViewModel>();
        }
Example #14
0
        private void RegistModel(SimpleContainer container) {

            var types = this.GetType().GetTypeInfo().Assembly.DefinedTypes
                .Select(t => new { T = t, Mode = t.GetCustomAttribute<RegistAttribute>()?.Mode })
                .Where(o => o.Mode != null && o.Mode != InstanceMode.None);

            foreach (var t in types) {
                var type = t.T.AsType();
                if (t.Mode == InstanceMode.Singleton) {
                    container.RegisterSingleton(type, null, type);
                } else if (t.Mode == InstanceMode.PreRequest) {
                    container.RegisterPerRequest(type, null, type);
                }
            }

            //container
            //    .Singleton<TabViewModel>()
            //    .Singleton<SettingViewModel>()
            //    .Singleton<MDIViewModel>()
            //    .Singleton<IndexViewModel>()
            //    .Singleton<SearchViewModel>()
            //    .Singleton<CompanyPositionsViewModel>()
            //    .Singleton<MyViewModel>()
            //    .Singleton<LoginViewModel>()
            //    .Singleton<FavoritesViewModel>()

            //    .PerRequest<CitySelectorViewModel>()
            //    .PerRequest<JobDetailViewModel>()
            //    .PerRequest<SearchedItemViewModel>()
            //    ;
        }
Example #15
0
        protected override void Configure()
        {
            _container = new SimpleContainer();
            IoC.Initialize(_container);

            _container.RegisterSingleton<INavigationService, FrameAdapter>();
            _container.RegisterSingleton<IEventAggregator, EventAggregator>();
            _container.RegisterSingleton<IViewModelLocator, ViewModelLocator>();
            _container.RegisterSingleton<IViewModelBinder, ViewModelBinder>();

            var typeResolver = new NameBasedViewModelTypeResolver();
            typeResolver.AddAssembly(typeof(App).GetTypeInfo().Assembly);
            _container.RegisterInstance<IViewModelTypeResolver>(typeResolver);

            _container.RegisterSingleton<MainPageViewModel>();
        }
Example #16
0
        protected override void Configure()
        {
            _simpleContainer = new SimpleContainer();

            try
            {
                _simpleContainer.RegisterInstance(typeof(IEventAggregator), "IEventAggregator", new EventAggregator());
                _simpleContainer.RegisterInstance(typeof(IWindowManager), "IWindowManager", new WindowManager());
                _simpleContainer.RegisterSingleton(typeof(ShellViewModel), "ShellViewModel", typeof(ShellViewModel));


                _simpleContainer.RegisterInstance(typeof(IProjectManager), "ProjectManager", new ProjectManager());
            }
            catch (Exception)
            {
                throw;
            }

            //_simpleContainer.RegisterInstance(typeof(ThemeManager), "ThemeManager", new ThemeManager());

            //ILogonService logonService = new LogOnService();
            //_simpleContainer.RegisterInstance(typeof(ILogonService), "ILogonService", logonService);
            //_simpleContainer.RegisterInstance(typeof(ILicenseService), "ILicenseService", new LicenseService(logonService));

            //ISystemLicenses systemLicensesService = new SystemLicenseService();
            //Task.Run(() => systemLicensesService.RefreshData());
            //_simpleContainer.RegisterInstance(typeof(ISystemLicenses), "ISystemLicenses", systemLicensesService);
            //_simpleContainer.RegisterInstance(typeof(IVerifyLicense), "IVerifyLicense", new VerifyLicenseService());

            base.Configure();
        }
Example #17
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            //Note: Explicitly creating the container.
            var container = new SimpleContainer();

            CaliburnFramework
                .ConfigureCore(container) //Note: Setting the container.
                .WithPresentationFramework()
                .Start();

            //Note: Registering commands by key.
            container.RegisterSingleton<ShowMessageCommand>("ShowMessage");
            container.RegisterSingleton<ShowTitledMessageCommand>("ShowTitledMessage");

            RootVisual = new Page();
        }
Example #18
0
        protected override void Configure()
        {
            _container = new SimpleContainer();
            IoC.Initialize(_container);

            _container.RegisterSingleton <INavigationService, FrameAdapter>();
            _container.RegisterSingleton <IEventAggregator, EventAggregator>();
            _container.RegisterSingleton <IViewModelLocator, ViewModelLocator>();
            _container.RegisterSingleton <IViewModelBinder, ViewModelBinder>();

            var typeResolver = new NameBasedViewModelTypeResolver();

            typeResolver.AddAssembly(typeof(App).GetTypeInfo().Assembly);
            _container.RegisterInstance <IViewModelTypeResolver>(typeResolver);

            _container.RegisterSingleton <MainPageViewModel>();
        }
Example #19
0
 private void RegisterSingletons(SimpleContainer container)
 {
     _singletons.ForEach(kvp =>
     {
         Console.WriteLine($"Registering Singleton: {kvp.Value.Name} for {kvp.Key.Name}");
         container.RegisterSingleton(kvp.Key, null, kvp.Value);
     });
 }
        protected override void Configure()
        {
            _container = new SimpleContainer();
            IoC.Initialize(_container);

            _container.RegisterSingleton <IWindowManager, WindowManager>();
            _container.RegisterSingleton <IEventAggregator, EventAggregator>();
            _container.RegisterSingleton <IViewModelLocator, ViewModelLocator>();
            _container.RegisterSingleton <IViewModelBinder, ViewModelBinder>();

            var typeResolver = new ViewModelTypeResolver();

            typeResolver.AddMapping <ShellView, ShellViewModel>();
            _container.RegisterInstance <IViewModelTypeResolver>(typeResolver);

            _container.RegisterPerRequest <ShellViewModel>();
        }
Example #21
0
        public override void InitializeIntegrations()
        {
            var scGen = new Mock <IScreenshotGenerator>();

            scGen.Setup(m => m.Process(It.IsAny <string>())).Returns(() => ScreenshotUrl);

            SimpleContainer.RegisterSingleton <IScreenshotGenerator>(() => scGen.Object);
        }
Example #22
0
        protected override void Configure()
        {
            _container = new SimpleContainer();

            _container.RegisterSingleton(typeof(MainWindowViewModel), "MainWindowViewModel", typeof(MainWindowViewModel));

            _container.RegisterInstance(typeof(IWindowManager), null, new WindowManager());
            _container.RegisterInstance(typeof(SimpleContainer), null, _container);
        }
        protected override void Configure()
        {
            container = new SimpleContainer();

            container.RegisterSingleton(typeof(IEventAggregator), null, typeof(EventAggregator));

            container.RegisterPerRequest(typeof(ShellViewModel), null, typeof(ShellViewModel));
            container.RegisterPerRequest(typeof(ShellView), null, typeof(ShellView));
        }
Example #24
0
 protected override void Configure()
 {
     _container = new SimpleContainer();
     _container.Singleton <IWindowManager, WindowManager>();
     _container.Singleton <IEventAggregator, EventAggregator>();
     _container.Singleton <IDataServiceLeveranciers, DataServiceLeveranciers>();
     _container.RegisterSingleton(typeof(Leveranciers), null, typeof(Leveranciers));
     _container.RegisterSingleton(typeof(Bestelbon), null, typeof(Bestelbon));
     _container.RegisterSingleton(typeof(PDFCreator), null, typeof(PDFCreator));
     _container.Singleton <ShellViewModel>();
     _container.Singleton <LeveranciersViewModel>();
     _container.Singleton <BestelbonsViewModel>();
     _container.Singleton <BestelbonOpmaakViewModel>();
     _container.Singleton <AddLeverancierViewModel>();
     _container.Singleton <DialogViewModel>();
     _container.Singleton <SelectUserViewModel>();
     _container.Singleton <LeveringsvoorwaardenViewModel>();
     _container.Singleton <UsersViewModel>();
     _container.Singleton <EditLeverancierViewModel>();
 }
Example #25
0
        protected override void Configure()
        {
            _container.PerRequest <IFileAccess, JsonFileAccess>();
            _container.PerRequest <IEncryptionManager, EncryptionManager>();
            _container.PerRequest <IWindowManager, WindowManager>();

            _container.RegisterInstance(typeof(Application), null, App.Current);
            _container.RegisterInstance(typeof(IEventAggregator), null, new EventAggregator());
            _container.RegisterInstance(typeof(ISnackbarMessageQueue), null, new SnackbarMessageQueue());
            _container.RegisterInstance(typeof(IRDCInstanceManager), null, new RDCInstanceManager(_container.GetInstance <ISnackbarMessageQueue>(), _container.GetInstance <IFileAccess>(), _container.GetInstance <IEncryptionManager>()));
            _container.RegisterInstance(typeof(IUserAccountManager), null, new UserAccountManager(_container.GetInstance <IFileAccess>(), _container.GetInstance <IEncryptionManager>()));
            _container.RegisterInstance(typeof(IRDCGroupManager), null, new RDCGroupManager(_container.GetInstance <IFileAccess>()));
            _container.RegisterInstance(typeof(IApplicationWrapper), null, new ApplicationWrapper(_container.GetInstance <Application>()));

            _container.RegisterSingleton(typeof(ShellViewModel), null, typeof(ShellViewModel));
            _container.RegisterSingleton(typeof(RDCSessionViewModel), null, typeof(RDCSessionViewModel));
            _container.RegisterSingleton(typeof(RDCCollectionViewModel), null, typeof(RDCCollectionViewModel));
            _container.RegisterSingleton(typeof(RDCUserAccountsViewModel), null, typeof(RDCUserAccountsViewModel));
            _container.RegisterSingleton(typeof(RDCGroupsViewModel), null, typeof(RDCGroupsViewModel));
        }
        public System.Threading.Tasks.Task InitializeAsync()
        {
            _container.RegisterSingleton
            (
                typeof(IFarmerRepository),
                FarmerRepositoryConstants.FarmerRepository.ToString(),
                typeof(MockFarmerRepository)
            );

            return(Task.FromResult <object>(null));
        }
Example #27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="App" /> class.
        /// </summary>
        /// <exception cref="T:System.InvalidOperationException">
        /// More than one instance of the <see cref="T:System.Windows.Application" /> class is created per <see cref="T:System.AppDomain" />.
        /// </exception>
        public App()
        {
            var container = new SimpleContainer();

            CaliburnFramework
            .ConfigureCore(container)
            .WithPresentationFramework()
            .Start();

            // Note: register all application commands here
            container.RegisterSingleton <ClosePanelCommand>("ClosePanel");
            container.RegisterSingleton <NavigateToCurrentNodeCommand>("NavigateToCurrentNode");
            container.RegisterSingleton <NavigateToParentNodeCommand>("NavigateToParentNode");
            container.RegisterSingleton <RefreshChildNodesCommand>("RefreshChildNodes");
            container.RegisterSingleton <DublicateSelectedPanelCommand>("DublicateSelectedPanel");
            container.RegisterSingleton <SwitchThemeCommand>("SwitchTheme");
            container.RegisterSingleton <SwapStackContainerOrientationCommand>("SwapStackContainerOrientation");
            container.RegisterSingleton <SplitTabContainerCommand>("SplitTabContainer");
            container.RegisterSingleton <WrapPanelWithTabContainerCommand>("WrapPanelWithTabContainer");
            container.RegisterSingleton <TogglePanelHeaderCommand>("TogglePanelHeader");
        }
Example #28
0
        public App()
        {
            //Note: Explicitly creating the container.
            var container = new SimpleContainer();

            CaliburnFramework
                .ConfigureCore(container) //Note: Setting the container.
                .WithPresentationFramework()
                .Start();

            //Note: Register the custom IAvailabilityEffect by key.
            container.RegisterSingleton<OpacityEffect>("Opacity");
        }
Example #29
0
        private void RegistInstances(SimpleContainer _container) {
            var types = this.GetType().GetTypeInfo().Assembly.DefinedTypes
                .Select(t => new { T = t, Mode = t.GetCustomAttribute<RegistAttribute>()?.Mode })
                .Where(o => o.Mode != null && o.Mode != InstanceMode.None);

            foreach (var t in types) {
                var type = t.T.AsType();
                if (t.Mode == InstanceMode.Singleton) {
                    _container.RegisterSingleton(type, null, type);
                } else if (t.Mode == InstanceMode.PreRequest) {
                    _container.RegisterPerRequest(type, null, type);
                }
            }
        }
Example #30
0
        public void Register(Type service, Type implementation, string key, Scope scope)
        {
            switch (scope)
            {
            case Scope.Singleton:
                container.RegisterSingleton(service, key, implementation);
                break;

            case Scope.PerRequest:
            default:
                container.RegisterPerRequest(service, key, implementation);
                break;
            }
        }
Example #31
0
    /// <summary>
    /// Registers all specified types in an assembly as singletong in the container.
    /// </summary>
    /// <typeparam name="TService">The type of the service.</typeparam>
    /// <param name="container">The container.</param>
    /// <param name="assembly">The assembly.</param>
    /// <param name="filter">The type filter.</param>
    /// <returns>The container.</returns>
    public static SimpleContainer AllTypesOf <TService>(this SimpleContainer container, Assembly assembly, Func <Type, bool> filter = null)
    {
        if (filter == null)
        {
            filter = type => true;
        }

#if WinRT
        var serviceInfo = typeof(TService).GetTypeInfo();
        var types       = from type in assembly.DefinedTypes
                          let info = type
                                     where serviceInfo.IsAssignableFrom(info) &&
                                     !info.IsAbstract &&
                                     !info.IsInterface &&
                                     filter(type.GetType())
                                     select type;
#else
        var serviceType = typeof(TService);
        var types       = from type in assembly.GetTypes()
                          where serviceType.IsAssignableFrom(type) &&
                          !type.IsAbstract &&
                          !type.IsInterface &&
                          filter(type)
                          select type;
#endif

        foreach (var type in types)
        {
#if WinRT
            container.RegisterSingleton(typeof(TService), null, type.GetType());
#else
            container.RegisterSingleton(typeof(TService), null, type);
#endif
        }

        return(container);
    }
Example #32
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            //Note: Explicitly creating the container.
            var container = new SimpleContainer();

            CaliburnFramework
                .ConfigureCore(container) //Note: Setting the container.
                .WithPresentationFramework()
                .Start();

            //Note: Register the custom IAvailabilityEffect by key.
            container.RegisterSingleton<OpacityEffect>("Opacity");

            RootVisual = new Page();
        }
Example #33
0
        protected override void Configure()
        {
            _container = new SimpleContainer();

            _container.RegisterPerRequest(typeof(ContactEditorViewModel), "ContactEditorViewModel", typeof(ContactEditorViewModel));
            _container.RegisterPerRequest(typeof(EditSensorViewModel), "EditSensorViewModel", typeof(EditSensorViewModel));
            _container.RegisterPerRequest(typeof(SpecifyValueViewModel), "SpecifyValueViewModel", typeof(SpecifyValueViewModel));
            _container.RegisterPerRequest(typeof(SensorTemplateManagerViewModel), "SensorTemplateManagerViewModel", typeof(SensorTemplateManagerViewModel));
            _container.RegisterPerRequest(typeof(ExportViewModel), "ExportViewModel", typeof(ExportViewModel));
            _container.RegisterPerRequest(typeof(SettingsViewModel), "SettingsViewModel", typeof(SettingsViewModel));
            _container.RegisterSingleton(typeof(LogWindowViewModel), "LogWindowViewModel", typeof(LogWindowViewModel));
            _container.RegisterPerRequest(typeof(ExportToImageViewModel), "ExportToImageViewModel", typeof(ExportToImageViewModel));
            _container.RegisterPerRequest(typeof(UseSelectedRangeViewModel), "UseSelectedRangeViewModel", typeof(UseSelectedRangeViewModel));
            _container.RegisterSingleton(typeof(MainWindowViewModel), "MainWindowViewModel", typeof(MainWindowViewModel));
            _container.RegisterPerRequest(typeof(EditSiteDataViewModel), "EditSiteDataViewModel", typeof(EditSiteDataViewModel));
            _container.RegisterPerRequest(typeof(MatchToExistingSensorsViewModel), "MatchToExistingSensorsViewModel", typeof(MatchToExistingSensorsViewModel));
            _container.RegisterPerRequest(typeof(CalibrationDetailsViewModel), "CalibrationDetailsViewModel", typeof(CalibrationDetailsViewModel));
            //_container.RegisterPerRequest(typeof(HeatMapViewModel), "HeatMapViewModel", typeof(HeatMapViewModel));
            _container.RegisterSingleton(typeof(AboutViewModel), "AboutViewModel", typeof(AboutViewModel));
            _container.RegisterSingleton(typeof(LoadInDataMetaViewModel), "LoadInDataMetaViewModel", typeof(LoadInDataMetaViewModel));

            _container.RegisterInstance(typeof(IWindowManager), null, new WindowManager());
            _container.RegisterInstance(typeof(SimpleContainer), null, _container);
        }
Example #34
0
        private void RegistInstances(SimpleContainer _container)
        {
            var types = this.GetType().GetTypeInfo().Assembly.DefinedTypes
                        .Select(t => new { T = t, Mode = t.GetCustomAttribute <RegisterCMAttributeAttribute>()?.Mode })
                        .Where(o => o.Mode != null && o.Mode != InstanceMode.None);

            foreach (var t in types)
            {
                var type = t.T.AsType();
                if (t.Mode == InstanceMode.Singleton)
                {
                    _container.RegisterSingleton(type, null, type);
                }
                else if (t.Mode == InstanceMode.PerRequest)
                {
                    _container.RegisterPerRequest(type, null, type);
                }
            }
        }
Example #35
0
        public static SimpleContainer AllTypesOf <TService>(this SimpleContainer target, Assembly assembly, ContainerRegistrationKind kind = ContainerRegistrationKind.PerRequest)
        {
            var serviceType = typeof(TService).GetTypeInfo();

            var types = assembly.DefinedTypes
                        .Where(type => serviceType.IsAssignableFrom(type) && !type.IsAbstract && !type.IsInterface);

            foreach (var typeInfo in types)
            {
                var type = typeInfo.AsType();
                if (kind == ContainerRegistrationKind.PerRequest)
                {
                    target.RegisterPerRequest(type, null, type);
                }
                else
                {
                    target.RegisterSingleton(type, null, type);
                }
            }

            return(target);
        }
Example #36
0
        public static void LoadViewModels(this SimpleContainer container, Assembly assembly)
        {
            var viewModels = assembly.GetTypes()
                             .Where(x => x.Namespace?.Contains($"ViewModels") == true &&
                                    x.FullName?.EndsWith("ViewModel") == true)
                             .ToList();

            foreach (var viewModel in viewModels)
            {
                var lifetime = viewModel.GetCustomAttribute <LifetimeScopeAttribute>();
                switch (lifetime?.LifetimeScope)
                {
                case LifetimeScope.Singletone:
                    container.RegisterSingleton(viewModel, viewModel.Name, viewModel);
                    break;

                default:
                    container.RegisterPerRequest(viewModel, viewModel.Name, viewModel);
                    break;
                }
            }
        }
Example #37
0
 /// <summary>
 /// Registers a singleton.
 /// </summary>
 /// <typeparam name="TImplementation">The type of the implementation.</typeparam>
 /// <param name="container">The container.</param>
 /// <returns>The container.</returns>
 public static SimpleContainer Singleton <TImplementation>(this SimpleContainer container)
 {
     container.RegisterSingleton(typeof(TImplementation), null, typeof(TImplementation));
     return(container);
 }
Example #38
0
        public void can_register_a_singleton_by_key()
        {
            container.RegisterSingleton("test", typeof(TestService));

            container.IsRegistered("test").ShouldBeTrue();
        }
Example #39
0
 protected override IServiceLocator CreateContainer()
 {
     var container = new SimpleContainer();
     container.RegisterSingleton<IStateManager, DeepLinkStateManager>();
     return container;
 }
Example #40
0
 public override void InitializeMessaging()
 {
     SimpleContainer.RegisterSingleton <IMessageService>(() => new InMemoryTransientMessageService());
 }
Example #41
0
 public static void RegisterSingleton <TService, TImplementation>(this SimpleContainer container)
     where TImplementation : TService
 {
     container.RegisterSingleton(typeof(TService), null, typeof(TImplementation));
 }