本文整理汇总了C#中System.ComponentModel.Composition.Hosting.TypeCatalog类的典型用法代码示例。如果您正苦于以下问题:C# TypeCatalog类的具体用法?C# TypeCatalog怎么用?C# TypeCatalog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeCatalog类属于System.ComponentModel.Composition.Hosting命名空间,在下文中一共展示了TypeCatalog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetupMultipleFactories
public void SetupMultipleFactories()
{
var catalog = new TypeCatalog(typeof(PartA), typeof(PartB), typeof(PartThatUsesACollectionOfFactories));
var ep = new ExportFactoryProvider();
_container = new CompositionContainer(catalog, ep);
ep.SourceProvider = _container;
}
示例2: 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));
}
示例3: 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();
}
示例4: TypeCatalog
public void When_removing_a_part_from_the_intercepted_catalog_intercepting_catalog_is_recomposed_and_removes_that_part()
{
var innerCatalog1 = new TypeCatalog(typeof(RecomposablePart1), typeof(RecomposablePartImporter));
var innerCatalog2 = new TypeCatalog(typeof(RecomposablePart2));
var cfg = new InterceptionConfiguration().AddInterceptor(new RecomposablePartInterceptor());
var aggregateCatalog = new AggregateCatalog(innerCatalog1, innerCatalog2);
var catalog = new InterceptingCatalog(aggregateCatalog, cfg);
container = new CompositionContainer(catalog);
var importer = container.GetExportedValue<RecomposablePartImporter>();
Assert.That(importer, Is.Not.Null);
Assert.That(importer.Parts, Is.Not.Null);
Assert.That(importer.Parts.Length, Is.EqualTo(2));
Assert.That(importer.Parts[0].Count, Is.EqualTo(1));
Assert.That(importer.Parts[1].Count, Is.EqualTo(1));
Assert.That(catalog.Parts.Count(), Is.EqualTo(3));
// Recompose
aggregateCatalog.Catalogs.Remove(innerCatalog2);
Assert.That(importer, Is.Not.Null);
Assert.That(importer.Parts, Is.Not.Null);
Assert.That(importer.Parts.Length, Is.EqualTo(1));
Assert.That(importer.Parts[0].Count, Is.EqualTo(1));
Assert.That(catalog.Parts.Count(), Is.EqualTo(2));
}
示例5: Prepare
public override void Prepare()
{
var basic = this.CreateBasic();
var propertyInjectionCatalog = new TypeCatalog(
typeof(ComplexPropertyObject1),
typeof(ComplexPropertyObject2),
typeof(ComplexPropertyObject3),
typeof(ServiceA),
typeof(ServiceB),
typeof(ServiceC),
typeof(SubObjectA),
typeof(SubObjectB),
typeof(SubObjectC));
var multipleCatalog = new TypeCatalog(
typeof(SimpleAdapterOne),
typeof(SimpleAdapterTwo),
typeof(SimpleAdapterThree),
typeof(SimpleAdapterFour),
typeof(SimpleAdapterFive),
typeof(ImportMultiple1),
typeof(ImportMultiple2),
typeof(ImportMultiple3));
var openGenericCatalog = new TypeCatalog(typeof(ImportGeneric<>), typeof(GenericExport<>));
this.container = new CompositionContainer(
new AggregateCatalog(basic.Item1, basic.Item2, basic.Item3, propertyInjectionCatalog, multipleCatalog, openGenericCatalog), true);
}
示例6: GetCatalog
protected override AggregateCatalog GetCatalog()
{
var typeCatalog = new TypeCatalog(
typeof(SettingsService), // persistent settings and user preferences dialog
typeof(CommandService), // handles commands in menus and toolbars
typeof(ControlHostService), // docking control host
typeof(AtfUsageLogger), // logs computer info to an ATF server
typeof(CrashLogger), // logs unhandled exceptions to an ATF server
typeof(UnhandledExceptionService), // catches unhandled exceptions, displays info, and gives user a chance to save
typeof(ContextRegistry), // central context registry with change notification
typeof(StandardFileExitCommand), // standard File exit menu command
typeof(FileDialogService), // standard Windows file dialogs
typeof(DocumentRegistry), // central document registry with change notification
typeof(StandardFileCommands), // standard File menu commands for New, Open, Save, SaveAs, Close
typeof(AutoDocumentService), // opens documents from last session, or creates a new document, on startup
typeof(RecentDocumentCommands), // standard recent document commands in File menu
typeof(MainWindowTitleService), // tracks document changes and updates main form title
typeof(WindowLayoutService), // service to allow multiple window layouts
typeof(WindowLayoutServiceCommands), // command layer to allow easy switching between and managing of window layouts
typeof(SchemaLoader), // loads schema and extends types
typeof(MainWindow), // main app window (analog to 'MainForm' in WinFormsApp)
typeof(Editor), // Sample editor class that creates and saves application documents
typeof(PythonService), // scripting service for automated tests
typeof(ScriptConsole), // provides a dockable command console for entering Python commands
typeof(AtfScriptVariables), // exposes common ATF services as script variables
typeof(AutomationService) // provides facilities to run an automated script using the .NET remoting service
);
return new AggregateCatalog(typeCatalog, StandardInteropParts.Catalog, StandardViewModels.Catalog);
}
示例7: CanImportSampleData
public void CanImportSampleData()
{
// Arrange
string httpClientFactoryContract = AttributedModelServices.GetContractName(typeof(IHttpClientFactory));
string routeServiceFactoryContract = AttributedModelServices.GetContractName(typeof(IRouteServiceFactory));
using (ApplicationCatalog initialCatalog = Program.BuildCompositionCatalog())
using (FilteredCatalog filteredCatalog = initialCatalog.Filter(d => !d.Exports(httpClientFactoryContract) && !d.Exports(routeServiceFactoryContract)))
using (TypeCatalog httpClientFactoryCatalog = new TypeCatalog(typeof(WtaResultFromEmbeddedResourceFactory)))
using (TypeCatalog routeServiceFactoryCatalog = new TypeCatalog(typeof(RouteServiceFromCalculatedDistanceFactory)))
using (AggregateCatalog aggregateCatalog = new AggregateCatalog(filteredCatalog, httpClientFactoryCatalog, routeServiceFactoryCatalog))
using (CompositionContainer container = new CompositionContainer(aggregateCatalog))
{
// Act
ITrailsImporter importer = container.GetExportedValue<ITrailsImporter>();
importer.Run();
}
using (MyTrailsContext context = new MyTrailsContext())
{
// Assert
ImportLogEntry logEntry = context.ImportLog
.OrderByDescending(le => le.Id)
.FirstOrDefault();
Assert.IsNotNull(logEntry);
Assert.IsNull(logEntry.ErrorString, message: logEntry.ErrorString);
Assert.AreEqual(0, logEntry.ErrorsCount);
Assert.IsTrue(context.Trails.Any());
Assert.IsTrue(context.Guidebooks.Any());
Assert.IsTrue(context.Passes.Any());
Assert.IsTrue(context.TripReports.Any());
}
}
示例8: UnityContainer
public void Unity_registered_components_take_precedence_over_MEF_registered_components_if_querying_for_a_single_component_registered_in_both_containers()
{
// Setup
var unityContainer = new UnityContainer();
var typeCatalog = new TypeCatalog(typeof (Singleton));
// Register catalog and types
unityContainer.RegisterCatalog(typeCatalog);
unityContainer.RegisterType<ISingleton, Singleton>(new ContainerControlledLifetimeManager());
// Reset count
Singleton.Count = 0;
Assert.That(Singleton.Count, Is.EqualTo(0));
var singleton = unityContainer.Resolve<ISingleton>();
Assert.That(singleton, Is.Not.Null);
Assert.That(Singleton.Count, Is.EqualTo(1));
var mef = unityContainer.Resolve<CompositionContainer>();
var mefSingleton = mef.GetExportedValue<ISingleton>();
Assert.That(Singleton.Count, Is.EqualTo(1));
Assert.That(singleton, Is.SameAs(mefSingleton));
}
示例9: CreateGenericPart
private void CreateGenericPart(Type importDefinitionType)
{
var type = TypeHelper.BuildGenericType(importDefinitionType, _genericTypes);
_manufacturedParts.Add(type);
var typeCatalog = new TypeCatalog(type);
_catalog.Catalogs.Add(typeCatalog);
}
示例10: SetupSingleFactory
public void SetupSingleFactory()
{
var catalog = new TypeCatalog(typeof (PartA), typeof(PartThatUsesAFactory));
var ep = new ExportFactoryProvider();
_container = new CompositionContainer(catalog, ep);
ep.SourceProvider = _container;
}
示例11: GetCatalog
/// <summary>
/// Gets MEF AggregateCatalog for application</summary>
protected override AggregateCatalog GetCatalog()
{
// Because this app references both Atf.Gui.WinForms and Atf.Gui.Wpf, we need to explicitly call
// this function to register resources. If only one or the other assembly were referenced, this
// would be handled automatically by Atf.Gui.Resources, but since both are included it doesn't
// know which one to choose.
Sce.Atf.Wpf.Resources.Register();
var typeCatalog = new TypeCatalog(
typeof(SettingsService), // persistent settings and user preferences dialog
typeof(CommandService), // handles commands in menus and toolbars
typeof(ControlHostService), // docking control host
typeof(AtfUsageLogger), // logs computer info to an ATF server
typeof(CrashLogger), // logs unhandled exceptions to an ATF server
typeof(UnhandledExceptionService), // catches unhandled exceptions, displays info, and gives user a chance to save
typeof(ContextRegistry), // central context registry with change notification
typeof(StandardFileExitCommand), // standard File exit menu command
typeof(FileDialogService), // standard Windows file dialogs
typeof(DocumentRegistry), // central document registry with change notification
typeof(StandardFileCommands), // standard File menu commands for New, Open, Save, SaveAs, Close
typeof(AutoDocumentService), // opens documents from last session, or creates a new document, on startup
typeof(RecentDocumentCommands), // standard recent document commands in File menu
typeof(MainWindowTitleService), // tracks document changes and updates main form title
typeof(WindowLayoutService), // service to handle window layouts
typeof(SchemaLoader), // loads schema and extends types
typeof(MainWindow), // main app window (analog to 'MainForm' in WinFormsApp)
typeof(Editor), // Sample editor class that creates and saves application documents
typeof(PythonService), // scripting service for automated tests
typeof(ScriptConsole), // provides a dockable command console for entering Python commands
typeof(AtfScriptVariables), // exposes common ATF services as script variables
typeof(AutomationService) // provides facilities to run an automated script using the .NET remoting service
);
return new AggregateCatalog(typeCatalog, StandardInteropParts.Catalog, StandardViewModels.Catalog);
}
示例12: DefaultLifetimeForMefComponentsIsSingleton
public void DefaultLifetimeForMefComponentsIsSingleton()
{
var builder = new ContainerBuilder();
var catalog = new TypeCatalog(typeof(HasDefaultCreationPolicy));
builder.RegisterComposablePartCatalog(catalog);
AssertDisposalTrackerIsSingleton(builder);
}
示例13: AnyCreationPolicyDefaultsToShared
public void AnyCreationPolicyDefaultsToShared()
{
var builder = new ContainerBuilder();
var catalog = new TypeCatalog(typeof(HasAnyCreationPolicy));
builder.RegisterComposablePartCatalog(catalog);
AssertDisposalTrackerIsSingleton(builder);
}
示例14: RegisterTypeCatalogContaining
private static IContainer RegisterTypeCatalogContaining(params Type[] types)
{
var builder = new ContainerBuilder();
var catalog = new TypeCatalog(types);
builder.RegisterComposablePartCatalog(catalog);
var container = builder.Build();
return container;
}
示例15: GetDocumentStore
public static EmbeddableDocumentStore GetDocumentStore(Type clientIndex)
{
var store = GetDocumentStore();
var catalogue = new TypeCatalog(new[] { clientIndex });
IndexCreation.CreateIndexes(new CompositionContainer(catalogue), store);
return store;
}