本文整理汇总了C#中System.ComponentModel.Composition.Hosting.CompositionContainer.ComposeExportedValue方法的典型用法代码示例。如果您正苦于以下问题:C# CompositionContainer.ComposeExportedValue方法的具体用法?C# CompositionContainer.ComposeExportedValue怎么用?C# CompositionContainer.ComposeExportedValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ComponentModel.Composition.Hosting.CompositionContainer
的用法示例。
在下文中一共展示了CompositionContainer.ComposeExportedValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: ModuleInUnreferencedAssemblyInitializedByModuleInitializer
public void ModuleInUnreferencedAssemblyInitializedByModuleInitializer()
{
AssemblyCatalog assemblyCatalog = new AssemblyCatalog(GetPathToModuleDll());
CompositionContainer compositionContainer = new CompositionContainer(assemblyCatalog);
ModuleCatalog moduleCatalog = new ModuleCatalog();
Mock<MefFileModuleTypeLoader> mockFileTypeLoader = new Mock<MefFileModuleTypeLoader>();
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.IsTrue(wasInit);
}
示例3: Initialize
protected override void Initialize()
{
base.Initialize();
var exceptionDialog = new ExceptionDialog("http://code.google.com/p/notifypropertyweaver/issues/list", "NotifyPropertyWeaver");
try
{
using (var catalog = new AssemblyCatalog(GetType().Assembly))
using (var container = new CompositionContainer(catalog))
{
var menuCommandService = (IMenuCommandService) GetService(typeof (IMenuCommandService));
var errorListProvider = new ErrorListProvider(ServiceProvider.GlobalProvider);
container.ComposeExportedValue(exceptionDialog);
container.ComposeExportedValue(menuCommandService);
container.ComposeExportedValue(errorListProvider);
container.GetExportedValue<MenuConfigure>().RegisterMenus();
container.GetExportedValue<SolutionEvents>().RegisterSolutionEvents();
container.GetExportedValue<TaskFileReplacer>().CheckForFilesToUpdate();
}
}
catch (Exception exception)
{
exceptionDialog.HandleException(exception);
}
}
示例4: 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);
}
示例5: Main
static void Main()
{
var engine = new GUILayer.EngineDevice();
GC.KeepAlive(engine);
var catalog = new TypeCatalog(
typeof(ShaderPatcherLayer.Manager),
typeof(ShaderFragmentArchive.Archive),
typeof(NodeEditorCore.ShaderFragmentArchiveModel),
typeof(NodeEditorCore.ModelConversion),
typeof(NodeEditorCore.ShaderFragmentNodeCreator),
typeof(NodeEditorCore.DiagramDocument),
typeof(ExampleForm)
);
using (var container = new CompositionContainer(catalog))
{
container.ComposeExportedValue<ExportProvider>(container);
container.ComposeExportedValue<CompositionContainer>(container);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(container.GetExport<ExampleForm>().Value);
}
engine.Dispose();
}
示例6: Start
public void Start()
{
_documentStore = new EmbeddableDocumentStore
{
DataDirectory = "./continuity.db",
UseEmbeddedHttpServer = true,
};
_documentStore.Initialize();
var container = new CompositionContainer(
new AggregateCatalog(
new AssemblyCatalog(GetType().Assembly),
new AssemblyCatalog(typeof(IBus).Assembly),
new DirectoryCatalog("extensions")
));
container.ComposeExportedValue<IDocumentStore>(_documentStore);
container.ComposeExportedValue<IDocumentSession>(_documentStore.OpenSession());
container.ComposeExportedValue<IBus>(new StandardBus());
container.ComposeParts(this);
_kernel.Bind<IDocumentStore>().ToConstant(_documentStore);
_kernel.Bind<IDocumentSession>().ToMethod(c => _documentStore.OpenSession());
//var startupTasks = _kernel.GetAll<INeedToRunAtStartup>();
foreach (var task in StartupItems)
task.Run();
HttpServer.Start();
var config = _kernel.Get<ContinuityConfiguration>();
_serverAddress = "localhost";
_serverPort = config.Port.ToString();
}
示例7: Prepare
public void Prepare()
{
container = new CompositionContainer(
new AggregateCatalog(
new AssemblyCatalog(
typeof (ITypedPool).Assembly
),
new TypeCatalog(typeof (Registrator)),
new TypeCatalog(typeof(ResourcePool)),
new TypeCatalog(typeof (NotifiedElementGetter)),
new TypeCatalog(typeof (UnnotifiedElementGetter)),
new TypeCatalog(typeof (NotifiedElementPoster)),
new TypeCatalog(typeof (UnnotifiedElementPoster))));
_uplink = _mockRepository.DynamicMock<AnnouncerUplink>();
_downlink = _mockRepository.DynamicMock<AnnouncerDownlink>();
_downlink.Expect(k => k.Subscribe(null))
.IgnoreArguments()
.Repeat.Once();
_downlink.Replay();
container.ComposeExportedValue(_uplink);
container.ComposeExportedValue(_downlink);
var service = container.GetExportedValue<ICacheServicing>();
service.Initialize(new Settings
{
AutoSubscription = (TestContext.Properties["AutoSubscription"] as string)== "true"
}, container);
_pool = container.GetExportedValue<ITypedPool>();
_subscriptor = container.GetExportedValue<IAnnouncerSubscriptor>();
}
示例8: UnknownExportedModuleIsAddedAndInitializedByModuleInitializer
public void UnknownExportedModuleIsAddedAndInitializedByModuleInitializer()
{
var aggregateCatalog = new AggregateCatalog();
var compositionContainer = new CompositionContainer(aggregateCatalog);
var moduleCatalog = new ModuleCatalog();
var mockModuleTypeLoader = new Mock<MefXapModuleTypeLoader>(new DownloadedPartCatalogCollection());
compositionContainer.ComposeExportedValue<IModuleCatalog>(moduleCatalog);
compositionContainer.ComposeExportedValue<MefXapModuleTypeLoader>(mockModuleTypeLoader.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>();
var moduleManager =
new MefModuleManager(mockModuleInitializer.Object, moduleCatalog, mockLoggerFacade.Object);
aggregateCatalog.Catalogs.Add(new TypeCatalog(typeof(TestMefModule)));
compositionContainer.SatisfyImportsOnce(moduleManager);
moduleManager.Run();
Assert.IsTrue(wasInit);
Assert.IsTrue(moduleCatalog.Modules.Any(mi => mi.ModuleName == "TestMefModule"));
}
示例9: Preparation
public void Preparation()
{
container = MockHelper.InitializeContainer(new[] { typeof(IProjectionsCollector).Assembly, typeof(Element).Assembly }, new Type[0]);
var pool = new ResourcePool();
container.ComposeExportedValue(pool);
container.ComposeExportedValue(container);
Settings.NoCacheGarbageChecking = true;
}
示例10: Run
public virtual void Run()
{
Container = new CompositionContainer(new AggregateCatalog(Catalogs));
var mefServiceLocator = new MEFServiceLocator(Container);
ServiceLocator.SetProvider(() => mefServiceLocator);
Container.ComposeExportedValue(Container);
Container.ComposeExportedValue(ServiceLocator.Current);
ApplicationLoaded();
}
示例11: SetupCompositionContainer
private CompositionContainer SetupCompositionContainer()
{
var catalog = new AssemblyCatalog(Assembly.GetExecutingAssembly());
var container = new CompositionContainer(catalog);
container.ComposeExportedValue<BootstrapperApplication>(this);
container.ComposeExportedValue<Engine>(this.Engine);
container.ComposeExportedValue<IUIInteractionService>(this);
return container;
}
示例12: CompositionHost
/// <summary>
/// Initializes a new instance of the <see cref="CompositionHost" /> class.
/// </summary>
/// <param name="isThreadSafe">if set to <c>true</c> if the container is thread safe.</param>
public CompositionHost(bool isThreadSafe)
{
var catalog = new AggregateCatalog();
Contract.Assume(catalog.Catalogs != null);
_container = new CompositionContainer(catalog, isThreadSafe);
_container.ComposeExportedValue((ICompositionHost)this);
_container.ComposeExportedValue((IServiceProvider)this);
_container.ComposeExportedValue((ExportProvider)Container);
}
示例13: ApplicationStartup
protected virtual void ApplicationStartup(object sender, StartupEventArgs e)
{
Catalog = new AggregateCatalog(
new AssemblyCatalog(typeof(AppBase).Assembly)
);
Container = new CompositionContainer(Catalog);
Container.ComposeExportedValue(new ViewFactory(Container));
Container.ComposeExportedValue(new StateHandler(Container));
}
示例14: Preparation
public void Preparation()
{
container = MockHelper.InitializeContainer(new[] { typeof(IProjectionsCollector).Assembly, typeof(Element).Assembly }, new Type[0]);
var pool = new ResourcePool();
var writer = new TestWriter();
container.ComposeExportedValue(container);
container.ComposeExportedValue(pool);
container.ComposeExportedValue(writer);
container.GetExportedValue<ICacheServicing>().Initialize();
}
示例15: Application_Start
protected void Application_Start(object sender, EventArgs e)
{
var assembly = new AssemblyCatalog(typeof(Global).Assembly); //this is how to add curent assembly
var catalog = new AggregateCatalog();
catalog.Catalogs.Add(assembly);
catalog.Catalogs.Add(new DirectoryCatalog("bin")); //this is where our DLLs are located. "." is for WPF app, "bin" is for WEB app
var container = new CompositionContainer(catalog);
var mefServiceLocator = new MefServiceLocator(container);
ServiceLocator.SetLocatorProvider(() => mefServiceLocator);
container.ComposeExportedValue<IServiceLocator>(mefServiceLocator);
container.ComposeExportedValue(container);
}