static void Main(string[] args)
        {
            UnityContainer container = new UnityContainer();
            container.RegisterInstance<IServiceLocator>(new UnityServiceLocatorAdapter(container));

            container.RegisterType<IModuleInitializer, ModuleInitializer>();

            TextLogger logger = new TextLogger();
            container.RegisterInstance<ILoggerFacade>(logger);

            IEventAggregator eventAggregator = new EventAggregator();
            container.RegisterInstance<IEventAggregator>(eventAggregator);

            ModuleCatalog catalog = new ModuleCatalog();
            //catalog.AddModule(typeof(RFID.RFIDModule));
            catalog.AddModule(typeof(BookInformation.BookInformationModule));
            catalog.AddModule(typeof(BookLocation.BookLocationModule));
            container.RegisterInstance<IModuleCatalog>(catalog);

            container.RegisterType<IModuleManager, ModuleManager>();
            IModuleManager manager = container.Resolve<IModuleManager>();
            manager.Run();
            //测试RFID服务模块的功能
            //RFIDUnitTest.testRFID(container);
            /******/
            //测试串口服务的功能
            //SerialUnitTest.testSerial(container);
            //测试数据库功能
            DatabaseUnitTest.testAllDatabase(container);
        }
Beispiel #2
0
        protected override IModuleCatalog CreateModuleCatalog()
        {
            ModuleCatalog moduleCatalog = new Prism.Modularity.ModuleCatalog();

            moduleCatalog.AddModule(typeof(ToolBarModule));
            moduleCatalog.AddModule(typeof(ServicesModule));
            moduleCatalog.AddModule(typeof(ProductsModule));
            return(moduleCatalog);
        }
        protected override IModuleCatalog CreateModuleCatalog()
        {
            ModuleCatalog moduleCatalog = new Prism.Modularity.ModuleCatalog();

            moduleCatalog.AddModule(typeof(HeroVirtualTabletopModule), InitializationMode.OnDemand);

            return(moduleCatalog);
        }
        protected override IModuleCatalog CreateModuleCatalog()
        {
            ModuleCatalog catalog = new ModuleCatalog();
            catalog.AddModule(typeof(BLModule));
            catalog.AddModule(typeof(ModuleCateogryModule));
            catalog.AddModule(typeof(ModuleSubCateogryModule));
            catalog.AddModule(typeof(ModulePaSModule));
            //catalog.AddModule(typeof(PersonServiceModule));
            //catalog.AddModule(typeof(ModuleAModule));

            //catalog.AddModule(typeof(ServicesModule));
            //catalog.AddModule(typeof(ToolbarModule));
            //catalog.AddModule(typeof (PeopleModule));
            catalog.AddModule(typeof(StatusBarModule));


            //catalog.AddModule(typeof(SubCatModule));            
            return catalog;
        }
Beispiel #5
0
        protected override IModuleCatalog CreateModuleCatalog()
        {
            ModuleCatalog catalog = new ModuleCatalog();
            catalog.AddModule(new ModuleInfo()
            {
                ModuleName = typeof (Modules.RS485Port.RS485PortModule).Name,
                ModuleType = typeof (Modules.RS485Port.RS485PortModule).AssemblyQualifiedName
            });
            catalog.AddModule(new ModuleInfo()
            {
                ModuleName = typeof (Modules.TMCLCommands.TMCLCommandModule).Name,
                ModuleType = typeof (Modules.TMCLCommands.TMCLCommandModule).AssemblyQualifiedName
            });
            catalog.AddModule(new ModuleInfo()
            {
                ModuleName = typeof(Modules.DisplayCommander.DisplayCommanderModule).Name,
                ModuleType = typeof(Modules.DisplayCommander.DisplayCommanderModule).AssemblyQualifiedName
            });

            return catalog;
        }
Beispiel #6
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            var catalog = new ModuleCatalog();
            catalog.AddModule(typeof(ShellServicesModule));
            catalog.AddModule(typeof(FlatDarkThemeModule));
            catalog.AddModule(typeof(FlatLightThemeModule));
            catalog.AddModule(typeof(PreferencesModule));
            catalog.AddModule(typeof(ThemeModule));
            catalog.AddModule(typeof(SupportModule));
            catalog.AddModule(typeof(UtilitiesModule));
            catalog.AddModule(typeof(ConnectivityModule));

            var host = new UnityDesktopHost(Resources);
            host.Container.RegisterInstance(typeof(IModuleCatalog), catalog, new ContainerControlledLifetimeManager());
            host.UseNLog();
            host.Run();
        }
 protected override IModuleCatalog CreateModuleCatalog()
 {
     ModuleCatalog catalog = new ModuleCatalog();
     catalog.AddModule(typeof (ModuleAModule.ModuleAModule), InitializationMode.WhenAvailable);
     return catalog;
 }
 protected override IModuleCatalog CreateModuleCatalog()
 {
     ModuleCatalog moduleCatalog = new ModuleCatalog();
     moduleCatalog.AddModule(typeof(AirlineModule.AirlineModuleModule));
     return moduleCatalog;
 }
Beispiel #9
0
        public void CanAddModule4()
        {
            ModuleCatalog catalog = new ModuleCatalog();

            catalog.AddModule(typeof(MockModule), "DependsOn1", "DependsOn2");

            Assert.AreEqual(1, catalog.Modules.Count());
            Assert.AreEqual("MockModule", catalog.Modules.First().ModuleName);
            Assert.AreEqual(typeof(MockModule).AssemblyQualifiedName, catalog.Modules.First().ModuleType);
            Assert.AreEqual(InitializationMode.WhenAvailable, catalog.Modules.First().InitializationMode);
            Assert.AreEqual(2, catalog.Modules.First().DependsOn.Count);
            Assert.AreEqual("DependsOn1", catalog.Modules.First().DependsOn[0]);
            Assert.AreEqual("DependsOn2", catalog.Modules.First().DependsOn[1]);

        }
Beispiel #10
0
        public void CanAddModule1()
        {
            ModuleCatalog catalog = new ModuleCatalog();

            catalog.AddModule("Module", "ModuleType", InitializationMode.OnDemand, "DependsOn1", "DependsOn2");

            Assert.AreEqual(1, catalog.Modules.Count());
            Assert.AreEqual("Module", catalog.Modules.First().ModuleName);
            Assert.AreEqual("ModuleType", catalog.Modules.First().ModuleType);
            Assert.AreEqual(InitializationMode.OnDemand, catalog.Modules.First().InitializationMode);
            Assert.AreEqual(2, catalog.Modules.First().DependsOn.Count);
            Assert.AreEqual("DependsOn1", catalog.Modules.First().DependsOn[0]);
            Assert.AreEqual("DependsOn2", catalog.Modules.First().DependsOn[1]);

        }
Beispiel #11
0
        public void ShouldReturnInCorrectRetrieveOrderWhenCompletingListWithDependencies()
        {
            // A <- B <- C <- D,    C <- X
            var moduleA = CreateModuleInfo("A");
            var moduleB = CreateModuleInfo("B", "A");
            var moduleC = CreateModuleInfo("C", "B");
            var moduleD = CreateModuleInfo("D", "C");
            var moduleX = CreateModuleInfo("X", "C");

            var moduleCatalog = new ModuleCatalog();
            // Add the modules in random order
            moduleCatalog.AddModule(moduleB);
            moduleCatalog.AddModule(moduleA);
            moduleCatalog.AddModule(moduleD);
            moduleCatalog.AddModule(moduleX);
            moduleCatalog.AddModule(moduleC);

            var dependantModules = moduleCatalog.CompleteListWithDependencies(new[] { moduleD, moduleX }).ToList();

            Assert.AreEqual(5, dependantModules.Count);
            Assert.IsTrue(dependantModules.IndexOf(moduleA) < dependantModules.IndexOf(moduleB));
            Assert.IsTrue(dependantModules.IndexOf(moduleB) < dependantModules.IndexOf(moduleC));
            Assert.IsTrue(dependantModules.IndexOf(moduleC) < dependantModules.IndexOf(moduleD));
            Assert.IsTrue(dependantModules.IndexOf(moduleC) < dependantModules.IndexOf(moduleX));
        }
Beispiel #12
0
        public void StartupModuleDependentOnAnOnDemandModuleThrows()
        {
            var catalog = new ModuleCatalog();
            var moduleOnDemand = CreateModuleInfo("ModuleA");
            moduleOnDemand.InitializationMode = InitializationMode.OnDemand;
            catalog.AddModule(moduleOnDemand);
            catalog.AddModule(CreateModuleInfo("ModuleB", "ModuleA"));

            try
            {
                catalog.Validate();
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(ModularityException));
                Assert.AreEqual("ModuleB", ((ModularityException)ex).ModuleName);

                return;
            }

            Assert.Fail("Exception not thrown.");
        }
Beispiel #13
0
        public void LooseModuleIfDependentOnModuleInGroupThrows()
        {
            var catalog = new ModuleCatalog();
            catalog.Items.Add(new ModuleInfoGroup() { CreateModuleInfo("ModuleA") });
            catalog.AddModule(CreateModuleInfo("ModuleB", "ModuleA"));

            try
            {
                catalog.Validate();
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(ModularityException));
                Assert.AreEqual("ModuleB", ((ModularityException)ex).ModuleName);

                return;
            }

            Assert.Fail("Exception not thrown.");
        }
Beispiel #14
0
        public void ShouldAggregateGroupsAndLooseModuleInfos()
        {
            var catalog = new ModuleCatalog();
            ModuleInfo moduleInfo1 = new ModuleInfo();
            ModuleInfo moduleInfo2 = new ModuleInfo();
            ModuleInfo moduleInfo3 = new ModuleInfo();

            catalog.Items.Add(new ModuleInfoGroup() { moduleInfo1 });
            catalog.Items.Add(new ModuleInfoGroup() { moduleInfo2 });
            catalog.AddModule(moduleInfo3);

            Assert.AreEqual(3, catalog.Modules.Count());
            Assert.IsTrue(catalog.Modules.Contains(moduleInfo1));
            Assert.IsTrue(catalog.Modules.Contains(moduleInfo2));
            Assert.IsTrue(catalog.Modules.Contains(moduleInfo3));
        }
Beispiel #15
0
        public void CanAddModules()
        {
            var catalog = new ModuleCatalog();

            catalog.AddModule(typeof(MockModule));

            Assert.AreEqual(1, catalog.Modules.Count());
            Assert.AreEqual("MockModule", catalog.Modules.First().ModuleName);
        }
        public void DeclaredModuleWithTypeInUnreferencedAssemblyIsUpdatedWithTypeNameFromExportAttribute()
        {
            AggregateCatalog aggregateCatalog = new AggregateCatalog();
            CompositionContainer compositionContainer = new CompositionContainer(aggregateCatalog);

            var mockFileTypeLoader = new Mock<MefFileModuleTypeLoader>();
            mockFileTypeLoader.Setup(tl => tl.CanLoadModuleType(It.IsAny<ModuleInfo>())).Returns(true);


            ModuleCatalog moduleCatalog = new ModuleCatalog();
            ModuleInfo moduleInfo = new ModuleInfo { ModuleName = "MefModuleOne", ModuleType = "some type" };
            moduleCatalog.AddModule(moduleInfo);

            compositionContainer.ComposeExportedValue<IModuleCatalog>(moduleCatalog);
            compositionContainer.ComposeExportedValue<MefFileModuleTypeLoader>(mockFileTypeLoader.Object);

            bool wasInit = false;
            var mockModuleInitializer = new Mock<IModuleInitializer>();
            mockModuleInitializer.Setup(x => x.Initialize(It.IsAny<ModuleInfo>())).Callback(() => wasInit = true);

            var mockLoggerFacade = new Mock<ILoggerFacade>();

            MefModuleManager moduleManager = new MefModuleManager(
                mockModuleInitializer.Object,
                moduleCatalog,
                mockLoggerFacade.Object);

            compositionContainer.SatisfyImportsOnce(moduleManager);
            moduleManager.Run();

            Assert.IsFalse(wasInit);

            AssemblyCatalog assemblyCatalog = new AssemblyCatalog(GetPathToModuleDll());
            aggregateCatalog.Catalogs.Add(assemblyCatalog);

            compositionContainer.SatisfyImportsOnce(moduleManager);

            mockFileTypeLoader.Raise(tl => tl.LoadModuleCompleted += null, new LoadModuleCompletedEventArgs(moduleInfo, null));

            Assert.AreEqual(BuildMefSupportTypeName(), moduleInfo.ModuleType);
            Assert.IsTrue(wasInit);
        }