當前位置: 首頁>>代碼示例>>C#>>正文


C# Modularity.ModuleInfo類代碼示例

本文整理匯總了C#中Microsoft.Practices.Prism.Modularity.ModuleInfo的典型用法代碼示例。如果您正苦於以下問題:C# ModuleInfo類的具體用法?C# ModuleInfo怎麽用?C# ModuleInfo使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ModuleInfo類屬於Microsoft.Practices.Prism.Modularity命名空間,在下文中一共展示了ModuleInfo類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: EnsureModulesDiscovered

        private void EnsureModulesDiscovered()
        {
            ModulesConfigurationSection section = this.Store.RetrieveModuleConfigurationSection();

            if (section != null)
            {
                foreach (ModuleConfigurationElement element in section.Modules)
                {
                    IList<string> dependencies = new List<string>();

                    if (element.Dependencies.Count > 0)
                    {
                        foreach (ModuleDependencyConfigurationElement dependency in element.Dependencies)
                        {
                            dependencies.Add(dependency.ModuleName);
                        }
                    }

                    ModuleInfo moduleInfo = new ModuleInfo(element.ModuleName, element.ModuleType)
                    {
                        Ref = GetFileAbsoluteUri(element.AssemblyFile),
                        InitializationMode = element.StartupLoaded ? InitializationMode.WhenAvailable : InitializationMode.OnDemand
                    };
                    moduleInfo.DependsOn.AddRange(dependencies.ToArray());
                    AddModule(moduleInfo);
                }
            }
        }
開發者ID:selvendiranj,項目名稱:compositewpf-copy,代碼行數:28,代碼來源:ConfigurationModuleCatalog.Desktop.cs

示例2: WhenInitializingAModuleWithNoCatalogPendingToBeLoaded_ThenInitializesTheModule

        public void WhenInitializingAModuleWithNoCatalogPendingToBeLoaded_ThenInitializesTheModule()
        {
            var aggregateCatalog = new AggregateCatalog(new AssemblyCatalog(typeof(MefModuleInitializer).Assembly));
            var compositionContainer = new CompositionContainer(aggregateCatalog);
            compositionContainer.ComposeExportedValue(aggregateCatalog);

            var serviceLocatorMock = new Mock<IServiceLocator>();
            var loggerFacadeMock = new Mock<ILoggerFacade>();

            var serviceLocator = serviceLocatorMock.Object;
            var loggerFacade = loggerFacadeMock.Object;

            compositionContainer.ComposeExportedValue(serviceLocator);
            compositionContainer.ComposeExportedValue(loggerFacade);

            aggregateCatalog.Catalogs.Add(new TypeCatalog(typeof(TestModuleForInitializer)));

            var moduleInitializer = compositionContainer.GetExportedValue<IModuleInitializer>();

            var moduleInfo = new ModuleInfo("TestModuleForInitializer", typeof(TestModuleForInitializer).AssemblyQualifiedName);

            var module = compositionContainer.GetExportedValues<IModule>().OfType<TestModuleForInitializer>().First();

            Assert.IsFalse(module.Initialized);

            moduleInitializer.Initialize(moduleInfo);

            Assert.IsTrue(module.Initialized);
        }
開發者ID:selvendiranj,項目名稱:compositewpf-copy,代碼行數:29,代碼來源:MefModuleInitializerFixture.cs

示例3: WhenInitializingAModuleWithACatalogPendingToBeLoaded_ThenLoadsTheCatalogInitializesTheModule

        public void WhenInitializingAModuleWithACatalogPendingToBeLoaded_ThenLoadsTheCatalogInitializesTheModule()
        {
            var aggregateCatalog = new AggregateCatalog(new AssemblyCatalog(typeof(MefModuleInitializer).Assembly));
            var compositionContainer = new CompositionContainer(aggregateCatalog);
            compositionContainer.ComposeExportedValue(aggregateCatalog);

            var serviceLocatorMock = new Mock<IServiceLocator>();
            var loggerFacadeMock = new Mock<ILoggerFacade>();

            var serviceLocator = serviceLocatorMock.Object;
            var loggerFacade = loggerFacadeMock.Object;

            compositionContainer.ComposeExportedValue(serviceLocator);
            compositionContainer.ComposeExportedValue(loggerFacade);

            var moduleInitializer = compositionContainer.GetExportedValue<IModuleInitializer>();
            var repository = compositionContainer.GetExportedValue<DownloadedPartCatalogCollection>();

            var moduleInfo = new ModuleInfo("TestModuleForInitializer", typeof(TestModuleForInitializer).AssemblyQualifiedName);

            repository.Add(moduleInfo, new TypeCatalog(typeof(TestModuleForInitializer)));

            moduleInitializer.Initialize(moduleInfo);

            ComposablePartCatalog existingCatalog;
            Assert.IsFalse(repository.TryGet(moduleInfo, out existingCatalog));

            var module = compositionContainer.GetExportedValues<IModule>().OfType<TestModuleForInitializer>().First();

            Assert.IsTrue(module.Initialized);
        }
開發者ID:selvendiranj,項目名稱:compositewpf-copy,代碼行數:31,代碼來源:MefModuleInitializerFixture.cs

示例4: WhenItemsInCollection_TryGetReturnsTrueAndCatalog

        public void WhenItemsInCollection_TryGetReturnsTrueAndCatalog()
        {
            // Prepare
            ModuleInfo moduleInfo1 = new ModuleInfo();
            ModuleInfo moduleInfo2 = new ModuleInfo();
            ModuleInfo moduleInfo3 = new ModuleInfo();

            ComposablePartCatalog catalog1 = new TypeCatalog();
            ComposablePartCatalog catalog2 = new TypeCatalog();
            ComposablePartCatalog catalog3 = new TypeCatalog();

            DownloadedPartCatalogCollection target = new DownloadedPartCatalogCollection();

            target.Add(moduleInfo1, catalog1);
            target.Add(moduleInfo2, catalog2);
            target.Add(moduleInfo3, catalog3);

            // Act
            bool actual = target.TryGet(moduleInfo3, out catalog3);    
        
            // Verify
            Assert.IsTrue(actual);
            Assert.AreSame(catalog3, target.Get(moduleInfo3));
            
        }
開發者ID:xperiandri,項目名稱:PortablePrism,代碼行數:25,代碼來源:DownloadedPartCatalogCollectionFixture.cs

示例5: Initialize

		public void Initialize(ModuleInfo moduleInfo)
		{
			if(initialModuleLoadCompleted)
			{
				defaultInitializer.Initialize(moduleInfo);
				return;
			}
			
			// register Module in Module-Config-List
			moduleConfigs.Modules.FirstOrDefault(mc => mc.Name == moduleInfo.ModuleName).Module = moduleInfo;
			
			// All modules pre-loaded?
			if (!(moduleConfigs.Modules.Any(mc => mc.Module == null)))
			{
				// Sort modules
		    	moduleConfigs.Modules = moduleConfigs.Modules.OrderBy(mc => mc.Order).ToList();

				foreach (var config in moduleConfigs.Modules)
				{
					defaultInitializer.Initialize(config.Module);
				}

				initialModuleLoadCompleted = true;
			}
		}
開發者ID:miseeger,項目名稱:SharpDevelop.Templates,代碼行數:25,代碼來源:SortedModuleInitializer.cs

示例6: ShouldLoadDownloadedAssemblies

        public void ShouldLoadDownloadedAssemblies()
        {
            // NOTE: This test method uses a resource that is built in a pre-build event when building the project. The resource is a
            // dynamically generated XAP file that is built with the Mocks/Modules/createXap.bat batch file.
            // If this test is failing unexpectedly, it may be that the batch file is not working correctly in the current environment.

            var mockFileDownloader = new MockFileDownloader();
            const string moduleTypeName = "Microsoft.Practices.Prism.Tests.Mocks.Modules.RemoteModule, RemoteModuleA, Version=0.0.0.0";
            var remoteModuleUri = "http://MyModule.xap";
            var moduleInfo = new ModuleInfo() { Ref = remoteModuleUri };
            XapModuleTypeLoader typeLoader = new TestableXapModuleTypeLoader(mockFileDownloader);
            ManualResetEvent callbackEvent = new ManualResetEvent(false);

            typeLoader.LoadModuleCompleted += delegate(object sender, LoadModuleCompletedEventArgs e)
            {
                callbackEvent.Set();
            };

            typeLoader.LoadModuleType(moduleInfo);

            Assert.IsNull(Type.GetType(moduleTypeName));

            Stream xapStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Microsoft.Practices.Prism.Tests.Mocks.Modules.RemoteModules.xap");
            mockFileDownloader.InvokeOpenReadCompleted(new DownloadCompletedEventArgs(xapStream, null, false, mockFileDownloader.DownloadAsyncArgumentUserToken));
            Assert.IsTrue(callbackEvent.WaitOne(500));

            Assert.IsNotNull(Type.GetType(moduleTypeName));
        }
開發者ID:ssethi,項目名稱:TestFrameworks,代碼行數:28,代碼來源:XapModuleTypeLoaderFixture.cs

示例7: Initialize

		public void Initialize(ModuleInfo moduleInfo)
		{
			if(initialModuleLoadCompleted || moduleInfo.ModuleName.EndsWith("Modules.Splash"))
			{
				defaultInitializer.Initialize(moduleInfo);
				return;
			}
			
			moduleConfigs.Modules.FirstOrDefault(mc => mc.Name == moduleInfo.ModuleName).Module = moduleInfo;
			
			// All modules pre-loaded?
			if (!(moduleConfigs.Modules.Any(mc => mc.Module == null)))
			{
				// Sort modules
		    	moduleConfigs.Modules = moduleConfigs.Modules.OrderBy(mc => mc.Order).ToList();

				foreach (var config in moduleConfigs.Modules)
				{
					_eventAggregator.GetEvent<SplashInfoUpdateEvent>().Publish(new SplashInfoUpdateEvent {Info = config.Description});
					Thread.Sleep(1000); // Uncomment as you need ;-)
					defaultInitializer.Initialize(config.Module);
				}

				initialModuleLoadCompleted = true;
			}
		}
開發者ID:miseeger,項目名稱:SharpDevelop.Templates,代碼行數:26,代碼來源:SortedModuleInitializerSplash.cs

示例8: CreateModule

        /// <summary>
        /// Uses the container to resolve a new <see cref="IModule"/> by specifying its <see cref="Type"/>.
        /// </summary>
        /// <param name="moduleInfo">The module to create.</param>
        /// <returns>
        /// A new instance of the module specified by <paramref name="moduleInfo"/>.
        /// </returns>
        protected override IModule CreateModule(ModuleInfo moduleInfo)
        {
            // If there is a catalog that needs to be integrated with the AggregateCatalog as part of initialization, I add it to the container's catalog.
            ComposablePartCatalog partCatalog;
            if (this.downloadedPartCatalogs.TryGet(moduleInfo, out partCatalog))
            {
                if (!this.aggregateCatalog.Catalogs.Contains(partCatalog))
                {
                    this.aggregateCatalog.Catalogs.Add(partCatalog);
                }

                this.downloadedPartCatalogs.Remove(moduleInfo);
            }

            if (this.ImportedModules != null && this.ImportedModules.Count() != 0)
            {
                Lazy<IModule, IModuleExport> lazyModule =
                    this.ImportedModules.FirstOrDefault(x => (x.Metadata.ModuleName == moduleInfo.ModuleName));
                if (lazyModule != null)
                {
                    return lazyModule.Value;
                }
            }

            // This does not fall back to the base implementation because the type must be in the MEF container and not just in the application domain.
            throw new ModuleInitializeException(
                string.Format(CultureInfo.CurrentCulture, Properties.Resources.FailedToGetType, moduleInfo.ModuleType));
        }
開發者ID:selvendiranj,項目名稱:compositewpf-copy,代碼行數:35,代碼來源:MefModuleInitializer.cs

示例9: HandleModuleInitializationError

        /// <summary>
        /// Handles any exception ocurred in the module Initialization process,
        /// logs the error using the <seealso cref="ILoggerFacade"/> and throws a <seealso cref="ModuleInitializeException"/>.
        /// This method can be overriden to provide a different behavior. 
        /// </summary>
        /// <param name="moduleInfo">The module metadata where the error happenened.</param>
        /// <param name="assemblyName">The assembly name.</param>
        /// <param name="exception">The exception thrown that is the cause of the current error.</param>
        /// <exception cref="ModuleInitializeException"></exception>
        public virtual void HandleModuleInitializationError(ModuleInfo moduleInfo, string assemblyName, Exception exception)
        {
            if (moduleInfo == null) throw new ArgumentNullException("moduleInfo");
            if (exception == null) throw new ArgumentNullException("exception");

            Exception moduleException;

            if (exception is ModuleInitializeException)
            {
                moduleException = exception;
            }
            else
            {
                if (!string.IsNullOrEmpty(assemblyName))
                {
                    moduleException = new ModuleInitializeException(moduleInfo.ModuleName, assemblyName, exception.Message, exception);
                }
                else
                {
                    moduleException = new ModuleInitializeException(moduleInfo.ModuleName, exception.Message, exception);
                }
            }

            this.loggerFacade.Log(moduleException.ToString(), Category.Exception, Priority.High);

            throw moduleException;
        }
開發者ID:CarlosVV,項目名稱:mediavf,代碼行數:36,代碼來源:ModuleInitializer.cs

示例10: LoadModuleType

        public void LoadModuleType(ModuleInfo moduleInfo)
        {
            if (moduleInfo == null)
            {
                throw new System.ArgumentNullException("moduleInfo");
            }

            try
            {
                // If this module has already been downloaded, I fire the completed event.
                if (this.IsSuccessfullyDownloaded(moduleInfo.ModuleType))
                {
                    this.RaiseLoadModuleCompleted(moduleInfo, null);
                }
                else
                {
                    // Although this isn't asynchronous, nor expected to take very long, I raise progress changed for consistency.
                    this.RaiseModuleDownloadProgressChanged(moduleInfo, 0, 100);

                    //

                    // Although this isn't asynchronous, nor expected to take very long, I raise progress changed for consistency.
                    this.RaiseModuleDownloadProgressChanged(moduleInfo, 100, 100);

                    // I remember the downloaded URI.
                    this.RecordDownloadSuccess(moduleInfo.Ref);

                    this.RaiseLoadModuleCompleted(moduleInfo, null);
                }
            }
            catch (Exception ex)
            {
                this.RaiseLoadModuleCompleted(moduleInfo, ex);
            }
        }
開發者ID:Nieko,項目名稱:Nieko,代碼行數:35,代碼來源:MemoryModuleTypeLoader.cs

示例11: CannotRetrieveWithIncorrectRef

        public void CannotRetrieveWithIncorrectRef()
        {
            var retriever = new FileModuleTypeLoader();
            var moduleInfo = new ModuleInfo() { Ref = "NotForLocalRetrieval" };

            Assert.IsFalse(retriever.CanLoadModuleType(moduleInfo));
        }
開發者ID:eslahi,項目名稱:prism,代碼行數:7,代碼來源:FileModuleTypeLoaderFixture.Desktop.cs

示例12: CanRetrieveWithCorrectRef

        public void CanRetrieveWithCorrectRef()
        {
            var retriever = new FileModuleTypeLoader();
            var moduleInfo = new ModuleInfo() { Ref = "file://somefile" };

            Assert.IsTrue(retriever.CanLoadModuleType(moduleInfo));
        }
開發者ID:eslahi,項目名稱:prism,代碼行數:7,代碼來源:FileModuleTypeLoaderFixture.Desktop.cs

示例13: CreateModuleInfo

        public ModuleInfo CreateModuleInfo()
        {
            ModuleInfo info = new ModuleInfo();
            info.ModuleName = "MefModuleOne";
            info.Ref = "file:///MefModulesForTesting.dll";

            return info;
        }
開發者ID:selvendiranj,項目名稱:compositewpf-copy,代碼行數:8,代碼來源:MefFileModuleTypeLoaderFixture.Desktop.cs

示例14: LoadModuleCompletedEventArgs

        /// <summary>
        /// Initializes a new instance of the <see cref="LoadModuleCompletedEventArgs"/> class.
        /// </summary>
        /// <param name="moduleInfo">The module info.</param>
        /// <param name="error">Any error that occurred during the call.</param>
        public LoadModuleCompletedEventArgs(ModuleInfo moduleInfo, Exception error)
        {
            if (moduleInfo == null) throw new ArgumentNullException("moduleInfo");
            Contract.EndContractBlock();

            this.ModuleInfo = moduleInfo;
            this.Error = error;
        }
開發者ID:ZeroInfinite,項目名稱:PortablePrism,代碼行數:13,代碼來源:LoadModuleCompletedEventArgs.cs

示例15: LoadModuleCompletedEventArgs

        /// <summary>
        /// Initializes a new instance of the <see cref="LoadModuleCompletedEventArgs"/> class.
        /// </summary>
        /// <param name="moduleInfo">The module info.</param>
        /// <param name="error">Any error that occurred during the call.</param>
        public LoadModuleCompletedEventArgs(ModuleInfo moduleInfo, Exception error)
        {
            if (moduleInfo == null) {
                throw new ArgumentNullException("moduleInfo");
            }

            this.ModuleInfo = moduleInfo;
            this.Error = error;
        }
開發者ID:michaelnero,項目名稱:SignalR-demos,代碼行數:14,代碼來源:LoadModuleCompletedEventArgs.cs


注:本文中的Microsoft.Practices.Prism.Modularity.ModuleInfo類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。