public void GetExport_ComplexConstraint_ExportSuccessful() { CompositionContext container = CreateContainer(typeof(UnrelatedThings <,>)); var exports = container.GetExports <IUnrelatedThings <IBook, ICar> >(); var types = exports.Select(h => h.GetType()); Assert.Equal(1, exports.Count()); Assert.Contains(typeof(UnrelatedThings <IBook, ICar>), types); }
public void GetExport_WhereClause_ExportSuccessful() { CompositionContext container = CreateContainer(typeof(InheritedThings <,>)); var exports = container.GetExports <IInheritedThings <IBook, IThing> >(); var types = exports.Select(h => h.GetType()); Assert.Equal(1, exports.Count()); Assert.Contains(typeof(InheritedThings <IBook, IThing>), types); }
public static IEnumerable <Lazy <TExtension, TMetadata> > TryGetExports <TExtension, TMetadata>(this CompositionContext compositionContext) { try { return(compositionContext.GetExports <Lazy <TExtension, TMetadata> >()); } catch (Exception) { return(null); } }
IEnumerable <Lazy <TExtension> > IMefHostExportProvider.GetExports <TExtension>() { return(_compositionContext.GetExports <TExtension>().Select(e => new Lazy <TExtension>(() => e))); }
private IEnumerable <IRequestStartup> GetRequestStartupTasks(CompositionContext container, Type[] requestStartupTypes) { return(container.GetExports <IRequestStartup>()); }
protected override IEnumerable <object> DoGetAllInstances(Type serviceType) { return(_host.GetExports(serviceType)); }
public IEnumerable <TFormat> Extend(CompositionContext context) { TFormat[] extensions = context.GetExports <TFormat>().ToArray(); AddRange(extensions); return(extensions); }