예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
 public static IEnumerable <Lazy <TExtension, TMetadata> > TryGetExports <TExtension, TMetadata>(this CompositionContext compositionContext)
 {
     try
     {
         return(compositionContext.GetExports <Lazy <TExtension, TMetadata> >());
     }
     catch (Exception)
     {
         return(null);
     }
 }
예제 #4
0
 IEnumerable <Lazy <TExtension> > IMefHostExportProvider.GetExports <TExtension>()
 {
     return(_compositionContext.GetExports <TExtension>().Select(e => new Lazy <TExtension>(() => e)));
 }
예제 #5
0
 private IEnumerable <IRequestStartup> GetRequestStartupTasks(CompositionContext container, Type[] requestStartupTypes)
 {
     return(container.GetExports <IRequestStartup>());
 }
 protected override IEnumerable <object> DoGetAllInstances(Type serviceType)
 {
     return(_host.GetExports(serviceType));
 }
예제 #7
0
 public IEnumerable <TFormat> Extend(CompositionContext context)
 {
     TFormat[] extensions = context.GetExports <TFormat>().ToArray();
     AddRange(extensions);
     return(extensions);
 }