Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 4
0
 IEnumerable <Lazy <TExtension> > IMefHostExportProvider.GetExports <TExtension>()
 {
     return(_compositionContext.GetExports <TExtension>().Select(e => new Lazy <TExtension>(() => e)));
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 7
0
 public IEnumerable <TFormat> Extend(CompositionContext context)
 {
     TFormat[] extensions = context.GetExports <TFormat>().ToArray();
     AddRange(extensions);
     return(extensions);
 }