public void HasHandler_returns_true_when_handler_exists() {
     var container = new SimpleContainer();
     container.RegisterPerRequest(typeof (object), "Object", typeof (object));
     
     Assert.True(container.HasHandler(typeof (object), null));
     Assert.True(container.HasHandler(null, "Object"));
 }
Esempio n. 2
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>();
            typeResolver.AddMapping<TabView, TabViewModel>();
            _container.RegisterInstance<IViewModelTypeResolver>(typeResolver);

            _container.RegisterPerRequest<ShellViewModel>();
            _container.RegisterPerRequest<TabViewModel>();
        }
Esempio n. 4
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>();
            _container.RegisterPerRequest<PublisherViewModel>();
            _container.RegisterPerRequest<SubscriberViewModel>();
        }
Esempio n. 5
0
        protected override void Configure()
        {
            container.Instance(container);
            container
            .Singleton <IWindowManager, WindowManager>()
            .Singleton <IMessageService, MessageBoxService>();

            GetType().Assembly.GetTypes()
            .Where(type => type.IsClass)
            .Where(type => type.Name.EndsWith("ViewModel"))
            .ToList()
            .ForEach(viewModelType => container.RegisterPerRequest(
                         viewModelType, viewModelType.ToString(), viewModelType));
        }
Esempio n. 6
0
        protected override void Configure()
        {
            _container.Instance(_container);

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

            GetType().Assembly.GetTypes().Where(type => type.IsClass)
            .Where(type => type.Name.EndsWith("ViewModel"))
            .ToList()
            .ForEach(viewModelType => _container.RegisterPerRequest(
                         viewModelType, viewModelType.ToString(), viewModelType));
        }
Esempio n. 7
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);
                }
            }
        }
Esempio n. 8
0
 private static void RegisterAllComponents(SimpleContainer container)
 {
     container.RegisterPerRequest(typeof(IComponent), null, typeof(Component));
     container.RegisterPerRequest(typeof(IDependency1), null, typeof(Dependency1));
     container.RegisterPerRequest(typeof(IDependency2), null, typeof(Dependency2));
     container.RegisterPerRequest(typeof(NonInterfaceDependency), null, typeof(NonInterfaceDependency));
     container.RegisterPerRequest(typeof(IEnumerableDependency), null, typeof(EnumerableDependency1));
     container.RegisterPerRequest(typeof(IEnumerableDependency), null, typeof(EnumerableDependency2));
 }
        protected override void Configure()
        {
            container.Instance(container);
            container
            .Singleton <IWindowManager, WindowManager>()
            .Singleton <IDeviceValidator, DeviceValidator>()
            .Singleton <IDataRepository, DataRepository>()
            .Singleton <INotificationService, NotificationService>();

            GetType().Assembly.GetTypes()
            .Where(type => type.IsClass)
            .Where(type => type.Name.EndsWith("ViewModel"))
            .ToList()
            .ForEach(viewModelType => container.RegisterPerRequest(
                         viewModelType, viewModelType.ToString(), viewModelType));
        }
Esempio n. 10
0
        protected override void Configure()
        {
            _container.Singleton <IWindowManager, WindowManager>();
            _container.PerRequest <ShellViewModel>();
            _container.PerRequest <IDataAccessDB, DataAccessByMemoryCache>();
            //_container.PerRequest<IDataAccessDB, RandomDataForTests>();
            _container.Singleton <IEventAggregator, EventAggregator>();
            _container.Singleton <IMotorService, MotorService>();

            GetType().Assembly.GetTypes()
            .Where(type => type.IsClass)
            .Where(type => type.Name.EndsWith("ViewModel"))
            .ToList()
            .ForEach(viewModelType => _container.RegisterPerRequest(
                         viewModelType, viewModelType.ToString(), viewModelType));
        }
Esempio n. 11
0
        protected override void Configure()
        {
            var defaultCreateTrigger = Parser.CreateTrigger;

            Parser.CreateTrigger = (target, triggerText) =>
            {
                if (triggerText == null)
                {
                    return(defaultCreateTrigger(target, null));
                }

                var triggerDetail = triggerText
                                    .Replace("[", string.Empty)
                                    .Replace("]", string.Empty);

                var splits = triggerDetail.Split((char[])null, StringSplitOptions.RemoveEmptyEntries);

                switch (splits[0])
                {
                case "Key":
                    var key = (Key)Enum.Parse(typeof(Key), splits[1], true);
                    return(new KeyTrigger {
                        Key = key
                    });

                case "Gesture":
                    var mkg = (MultiKeyGesture)(new MultiKeyGestureConverter()).ConvertFrom(splits[1]);
                    return(new KeyTrigger {
                        Modifiers = mkg.KeySequences[0].Modifiers, Key = mkg.KeySequences[0].Keys[0]
                    });
                }

                return(defaultCreateTrigger(target, triggerText));
            };

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

            GetType().Assembly.GetTypes()
            .Where(type => type.IsClass)
            .Where(Type => Type.Name.EndsWith("ViewModel"))
            .ToList()
            .ForEach(viewModelType => _container.RegisterPerRequest(viewModelType, viewModelType.ToString(), viewModelType));
            // _container.PerRequest<LoginDBViewModel>(); // Регистрирую вм окна аутентификации, выше зарегистрировал все вм
        }
Esempio n. 12
0
        protected override void Configure()
        {
            _container.Instance(_container);
            //Добавляем в контейнеры все наши интерфейсы и их реализацию
            _container
            .Singleton <IWindowManager, WindowManager>()
            .Singleton <IEventAggregator, EventAggregator>()
            .Singleton <IAPIHelpers, APIHelpers>();


            GetType().Assembly.GetTypes()
            .Where(type => type.IsClass)
            .Where(type => type.Name.EndsWith("ViewModel"))
            .ToList()
            .ForEach(ViewModelType => _container.RegisterPerRequest(
                         ViewModelType, ViewModelType.ToString(), ViewModelType));
        }
Esempio n. 13
0
        protected override void Configure()
        {
            _container.Instance(_container);
            //Dependency Injection
            _container
            .Singleton <IWindowManager, WindowManager>()
            .Singleton <IEventAggregator, EventAggregator>()
            .Singleton <IAPIHelper, APIHelper>();

            //Reflection acces jeden Class with end ViewModel and register per request
            GetType().Assembly.GetTypes()
            .Where(type => type.IsClass)
            .Where(type => type.Name.EndsWith("ViewModel"))
            .ToList()
            .ForEach(viewModelType => _container.RegisterPerRequest(
                         viewModelType, viewModelType.ToString(), viewModelType));
        }
Esempio n. 14
0
        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>();
        }
        protected override void Configure()
        {
            _container.Instance(_container)
            .PerRequest <IProductEndpoint, ProductEndpoint>();
            _container
            .Singleton <IWindowManager, WindowManager>()
            .Singleton <IEventAggregator, EventAggregator>()
            .Singleton <ILoggedInUserModel, LoggedInUserModel>()
            .Singleton <IConfigHelper, ConfigHelper>()
            .Singleton <IAPIHelper, APIHelper>();

            GetType().Assembly.GetTypes()
            .Where(type => type.IsClass)
            .Where(type => type.Name.EndsWith("ViewModel"))
            .ToList()
            .ForEach(ViewModelType => _container.RegisterPerRequest(ViewModelType, ViewModelType.ToString(), ViewModelType));
        }
Esempio n. 16
0
        protected override void Configure()
        {
            _container.Instance(_container);

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

            GetType().Assembly.GetTypes()                                          //get all types in the problem
            .Where(type => type.IsClass)                                           //limit to only classes
            .Where(type => type.Name.EndsWith("ViewModel"))                        //limit to only classes which end with "ViewModel"
            .ToList()                                                              //make a list
            .ForEach(viewModelType => _container.RegisterPerRequest(
                         viewModelType, viewModelType.ToString(), viewModelType)); //which each entry, get service,key,implementation.
            //TODO makes it harder to unit test; might change to interfaces later.
        }
Esempio n. 17
0
        //Now where does the actual instantiation happen OR where does container know what to do what
        //Will use configure method for this
        protected override void Configure()
        {
            _container.Instance(_container);

            _container
            .Singleton <IWindowManager, WindowManager>()
            .Singleton <IEventAggregator, EventAggregator>()
            .Singleton <ILoggedInUserModel, LoggedInUserModel>()
            .Singleton <IAPIHelper, APIHelper>();

            //Connect ViewModels to View using reflection
            GetType().Assembly.GetTypes()
            .Where(type => type.IsClass)
            .Where(type => type.Name.EndsWith("ViewModel"))
            .ToList()
            .ForEach(viewModelType => _container.RegisterPerRequest(
                         viewModelType, viewModelType.ToString(), viewModelType));
        }
Esempio n. 18
0
        protected override void Configure()
        {
            _container.Instance(_container);

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

            //Haetaan kaikki tyypit nykyiselle instanssille (Assembly).
            //Rajoitetaan haku luokkiin ja haetaan luokista nimet, jotka loppuvat ViewModeliin.
            //Lista käydään läpi ja _container rekisteröi luokkien tyypit ja nimet joka kerta, kun niitä pyydetään.
            GetType().Assembly.GetTypes()
            .Where(type => type.IsClass)
            .Where(type => type.Name.EndsWith("ViewModel"))
            .ToList()
            .ForEach(viewModelType => _container.RegisterPerRequest(
                         viewModelType, viewModelType.ToString(), viewModelType));
        }
Esempio n. 19
0
        protected override void Configure()
        {
            _container.Instance(_container);

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

            // making sure the assigned interface will always be this apihelper class
            .Singleton <IAPIHelper, APIHelper>();

            GetType().Assembly.GetTypes()
            .Where(type => type.IsClass)
            .Where(type => type.Name.EndsWith("ViewModel"))
            .ToList()
            .ForEach(viewModelType => _container.RegisterPerRequest(
                         viewModelType, viewModelType.ToString(), viewModelType));
        }
Esempio n. 20
0
        protected override void Configure()
        {
            //Esta es la manera que trabaja Caliber.Micro
            _container.Instance(_container);
            _container
            .Singleton <IWindowManager, WindowManager>()
            .Singleton <IEventAggregator, EventAggregator>();
            GetType().Assembly.GetTypes()
            .Where(type => type.IsClass)
            .Where(type => type.Name.EndsWith("ViewModel"))
            .ToList()
            .ForEach(viewModelType => _container.RegisterPerRequest(viewModelType, viewModelType.ToString(), viewModelType));
            //Ahora vamos a conectar los ViewModels con las Views

            // Lo que hace esto es: para cada clase en nuestro proyecto que
            // termine en 'ViewModel', la registro en mi _container
            // Hay algún quilombo si queremos hacer nUnit test a muestro proyecto
        }
Esempio n. 21
0
        protected override void Configure()
        {
            _containter.Instance(_containter);
            _containter
            .Singleton <IWindowManager, WindowManager>()
            .Singleton <IEventAggregator, EventAggregator>();

            _containter
            .PerRequest <IFormatterConfiguration, FormatterConfiguration>()
            .PerRequest <IFactory <PopUpViewModel>, PopUpViewModelFactory>();

            GetType().Assembly.GetTypes()
            .Where(type => type.IsClass)
            .Where(type => type.Name.EndsWith(VIEWMODEL_SUFFIX))
            .ToList()
            .ForEach(viewModelType => _containter.RegisterPerRequest(
                         viewModelType, viewModelType.ToString(), viewModelType));
        }
Esempio n. 22
0
        protected override void Configure()
        {
            container = new SimpleContainer();

            container.Singleton <IWindowManager, WindowManager>();
            container.Singleton <IEventAggregator, EventAggregator>();
            container.AllTypesOf <IMatchSerializer>(Assembly.GetExecutingAssembly());
            container.Singleton <IMatchManager, MatchManager>();
            container.Singleton <IReportGenerationQueueManager, ReportGenerationQueueManager>();
            container.Singleton <IShell, ShellViewModel>();
            container.Singleton <IDialogCoordinator, DialogCoordinator>();
            container.AllTypesOf <IResultViewTabItem>(Assembly.GetExecutingAssembly());
            // Report generation
            container.Singleton <IReportGenerator, DefaultReportGenerator>("default");
            container.Singleton <IReportGenerator, CustomizedReportGenerator>("customized");
            // Report rendering
            container.RegisterPerRequest(typeof(IReportRenderer), "PDF", typeof(PdfRenderer));
        }
Esempio n. 23
0
        protected override void Configure()
        {
            _container.Instance(_container)
            .PerRequest <IProductEndpoint, ProductEndpoint>();

            // Need to register the Caliburn parts required.
            _container.Singleton <IWindowManager, WindowManager>()
            .Singleton <IEventAggregator, EventAggregator>()
            .Singleton <ILoggedInUserViewModel, LoggedInUserModel>()
            .Singleton <IAPIHelper, APIHelper>();

            // Add all of your ViewModels
            GetType().Assembly.GetTypes()
            .Where(t => t.IsClass)
            .Where(t => t.Name.EndsWith("ViewModel"))
            .ToList()
            .ForEach(vmt => _container.RegisterPerRequest(vmt, vmt.ToString(), vmt));
        }
Esempio n. 24
0
        protected override void Configure()
        {
            _container.Instance(_container);

            _container
            .Singleton <IWindowManager, WindowManager>()
            .Singleton <IEventAggregator, EventAggregator>()
            // Should work. need to implement.
            .Singleton <IExceptionLogger, ExceptionLogger>();

            _container.PerRequest <IFileBrowser, FileBrowser>();

            GetType().Assembly.GetTypes().Where(type => type.IsClass)
            .Where(type => type.Name.EndsWith("ViewModel"))
            .ToList()
            .ForEach(viewModelType => _container.RegisterPerRequest(
                         viewModelType, viewModelType.ToString(), viewModelType));
        }
Esempio n. 25
0
        protected override void Configure()
        {
            _container.Instance(_container);

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

            _container.PerRequest <ISqliteDataAccess, SqliteDataAccess>();
            _container.PerRequest <IQueries, Queries>();
            _container.PerRequest <IAddTransactionFactory, AddTransactionFactory>();

            GetType().Assembly.GetTypes()
            .Where(type => type.IsClass)
            .Where(type => type.Name.EndsWith("ViewModel"))
            .ToList()
            .ForEach(viewModelType => _container.RegisterPerRequest(
                         viewModelType, viewModelType.ToString(), viewModelType));
        }
Esempio n. 26
0
        protected override void Configure()
        {
            // The container holds an instance of itself to pass out when asked for a simple container.
            _container.Instance(_container);

            // Singleton is One instance of the class for the life of the application.
            _container
            .Singleton <IWindowManager, WindowManager>()
            .Singleton <IEventAggregator, EventAggregator>()
            .Singleton <ILoggedInUserModel, LoggedInUserModel>()
            .Singleton <IAPIHelper, APIHelper>();

            GetType().Assembly.GetTypes()
            .Where(type => type.IsClass)
            .Where(type => type.Name.EndsWith("ViewModel"))
            .ToList()
            .ForEach(viewModelType => _container.RegisterPerRequest(
                         viewModelType, viewModelType.ToString(), viewModelType));
        }
Esempio n. 27
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);
                }
            }
        }
Esempio n. 28
0
        protected override void Configure()
        {
            //// AUTOMAPPER
            //// uses some reflection at the startup.
            //// This is the automapper configuration, step 1)
            //var config = new MapperConfiguration(cfg =>
            //{
            //    cfg.CreateMap<ProductModel, ProductDisplayModel>();
            //    cfg.CreateMap<CartItemModel, CartItemDisplayModel>();
            //});
            //// Now create the mapper, step 2)
            //var mapper = config.CreateMapper();
            //// Now add to Dependency Injection System, our Container, step 3)
            //_container.Instance(mapper);
            ////_container.Instance<IMapper>(mapper); it is redundant !!
            //// Use Constructor DI to use the mapper, step 4)
            //// Use mapper.Map<TargetStructure>(Source Object); step 5)
            // Above part was extracted to it's own method, ConfigureAutomapper.

            _container.Instance(ConfigureAutomapper());

            _container.Instance(_container)
            .PerRequest <IProductEndPoint, ProductEndPoint>()
            .PerRequest <ISaleEndPoint, SaleEndPoint>()
            .PerRequest <IUserEndPoint, UserEndPoint>();

            _container
            .Singleton <IWindowManager, WindowManager>()
            .Singleton <IEventAggregator, EventAggregator>()
            .Singleton <IAPIHelper, APIHelper>()
            .Singleton <ILoggedInUserModel, LoggedInUserModel>()
            .Singleton <IConfigHelper, ConfigHelper>();

            GetType().Assembly.GetTypes()
            .Where(type => type.IsClass)
            .Where(type => type.Name.EndsWith("ViewModel"))
            .ToList()
            .ForEach(viewModelType => _container.RegisterPerRequest(
                         viewModelType, viewModelType.ToString(), viewModelType));
            // we don't create interfaces for each ViewModel for now!
            // that's why we have viewModelType in both places above!
        }
Esempio n. 29
0
        /// <summary>
        /// Configures the bootstrapper
        /// </summary>
        protected override void Configure()
        {
            // Register the container
            container.Instance(container);

            // Add required singletons
            container
            .Singleton <IWindowManager, WindowManager>()
            .Singleton <IEventAggregator, EventAggregator>()
            .Singleton <IUser, User>()
            .Singleton <IDatabaseService, DatabaseService>();

            // Using LINQ combine the view with the view models
            GetType().Assembly.GetTypes()
            .Where(type => type.IsClass)
            .Where(type => type.Name.EndsWith("ViewModel"))
            .ToList()
            .ForEach(viewModelType => container.RegisterPerRequest(
                         viewModelType, viewModelType.ToString(), viewModelType));
        }
Esempio n. 30
0
        static Service()
        {
            Container = new SimpleContainer();
            Container.PerRequest <IAuthenticationService, AuthenticationService>();
            Container.PerRequest <ICatalogueService, CatalogueService>();
            Container.PerRequest <ICustomerService, CustomerService>();
            Container.PerRequest <ILoggingService, LoggingService>();
            Container.PerRequest <IMetricsService, MetricsService>();
            Container.PerRequest <IOrderService, OrderService>();
            Container.PerRequest <IShoppingCartService, ShoppingCartService>();

            //Register Controllers
            var baseType = typeof(HomeController);

            baseType.Assembly
            .GetTypes()
            .Where(t => baseType.IsAssignableFrom(t) && !t.IsAbstract && !t.IsInterface)
            .ForEach(controllerType =>
                     Container.RegisterPerRequest(controllerType, null, controllerType));
        }
Esempio n. 31
0
        public void BuildUp_Throws_When_Multiple_Types_Found_For_Component()
        {
            var container = new SimpleContainer();

            RegisterAllComponents(container);
            container.RegisterPerRequest(typeof(IDependency1), null, typeof(SecondDependency1));

            var instance = (Component)container.GetInstance <IComponent>();

            try
            {
                container.BuildUp(instance);
            }
            catch
            {
                return;
            }

            Assert.NotNull(null);
        }
Esempio n. 32
0
        protected override void Configure()
        {
            _container.Instance(_container);

            _container
            .Singleton <IWindowManager, WindowManager>()
            .Singleton <IEventAggregator, EventAggregator>()
            .Singleton <ILoggedInUserModel, LoggedInUserModel>()
            .Singleton <IAPIHelper, APIHelper>();

            //Using reflection to get all the ViewModels Classes and register
            //it on the container with "PerRequest" DI life cycle.
            //Transient
            GetType().Assembly.GetTypes()
            .Where(type => type.IsClass)
            .Where(type => type.Name.EndsWith("ViewModel"))
            .ToList()
            .ForEach(viewModelType => _container.RegisterPerRequest(
                         viewModelType, viewModelType.ToString(), viewModelType));
        }
Esempio n. 33
0
        protected override void Configure()
        {
            _container.Instance(_container)
            .PerRequest <IContactEndPoint, ContactEndPoint>();

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



            // Use reflection to get all models inside ViewModels folder
            GetType().Assembly.GetTypes()
            .Where(type => type.IsClass)
            .Where(type => type.Name.EndsWith("ViewModel"))
            .ToList()
            .ForEach(viewModelType => _container.RegisterPerRequest(
                         viewModelType, viewModelType.ToString(), viewModelType));
        }
Esempio n. 34
0
        protected override void Configure()
        {
            _container
            .Instance(_container)
            .PerRequest <IProductEndpoint, ProductEndpoint>();

            _container
            .Singleton <IWindowManager, WindowManager>()
            .Singleton <IEventAggregator, EventAggregator>()
            .Singleton <ILoggedInUserModel, LoggedInUserModel>()
            .Singleton <IConfigHelper, ConfigHelper>()
            .Singleton <IApiHelper, ApiHelper>();

            var viewModelTypes = GetType().Assembly.GetTypes().Where((t) => t.IsClass && t.Name.EndsWith("ViewModel"));

            foreach (var viewModelType in viewModelTypes)
            {
                _container.RegisterPerRequest(viewModelType, viewModelType.ToString(), viewModelType);
            }
        }
Esempio n. 35
0
        protected override void Configure()
        {
            _container.Instance(_container);

            _container
            .Singleton <IWindowManager, WindowManager>()
            .Singleton <IEventAggregator, EventAggregator>()
            .Singleton <IDeviceAccess, DeviceAccess>()
            .Singleton <IProducerAccess, ProducerAccess>()
            .Singleton <IProjectAccess, ProjectAccess>()
            .Singleton <ICustomerAccess, CustomerAccess>();

            // Register all ViewModels in App
            GetType().Assembly.GetTypes()
            .Where(type => type.IsClass)
            .Where(type => type.Name.EndsWith("ViewModel"))
            .ToList()
            .ForEach(viewModelType => _container.RegisterPerRequest(
                         viewModelType, viewModelType.ToString(), viewModelType));
        }
        public void Instances_can_be_found_by_name_only() {
            var container = new SimpleContainer();
            container.RegisterPerRequest(typeof(object), "AnObject", typeof(object));

            Assert.NotNull(container.GetInstance(null, "AnObject"));
        }
Esempio n. 37
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);
        }