Ejemplo n.º 1
0
        private void EnsureTransformers(IDocumentStore singleShardStore)
        {
            var catalog   = new System.ComponentModel.Composition.Hosting.AssemblyCatalog(typeof(TransformerTest).Assembly);
            var container = new System.ComponentModel.Composition.Hosting.CompositionContainer(catalog);

            container.ComposeParts();

            foreach (var task in container.GetExportedValues <AbstractTransformerCreationTask>())
            {
                task.Execute(singleShardStore);
            }
        }
Ejemplo n.º 2
0
        public override void OnExecute()
        {
            //权限校验

            //处理菜单
            var lstMenuInfo = MenuInfoHandler();

            this.ViewData["__menuInfo"] = lstMenuInfo;
            //注入
            //System.ComponentModel.Composition.Hosting.CompositionContainer container =
            //     System.AppDomain.CurrentDomain.GetData("__@@container") as System.ComponentModel.Composition.Hosting.CompositionContainer;
            container.ComposeParts(this);
        }
Ejemplo n.º 3
0
        public static PluginHost Create()
        {
            var builder = new System.ComponentModel.Composition.Registration.RegistrationBuilder();

            // addins
            builder
                .ForTypesDerivedFrom<IAddinContract>()
                //.Export<IAddinContract>()
                .ExportInterfaces()
                ;

            // host
            builder
                    .ForType<PluginHost>()
                    //.ImportProperty(x => x.Addins, b => b.AsMany())
                    .Export<PluginHost>()
                    ;

            var hostCatalog = new System.ComponentModel.Composition.Hosting.AssemblyCatalog(typeof(PluginHost).Assembly, builder);
            var aCataog = new System.ComponentModel.Composition.Hosting.AggregateCatalog(hostCatalog);

            #if false
            var catalog = new System.ComponentModel.Composition.Hosting.DirectoryCatalog("addins");
            aCataog.Catalogs.Add(catalog);
            #else
            foreach (var f in new DirectoryInfo("addins").GetFiles().Where(x => x.Name.ToLower().EndsWith(".dll")))
            {
                var catalog = new System.ComponentModel.Composition.Hosting.AssemblyCatalog(Assembly.LoadFile(f.FullName), builder);
                aCataog.Catalogs.Add(catalog);
            }
            #endif

            var container = new System.ComponentModel.Composition.Hosting.CompositionContainer(aCataog);
            #if false
            var host = new PluginHost();
            container.ComposeParts(host);
            return host;
            #else
            return container.GetExportedValue<PluginHost>();
            #endif
        }
Ejemplo n.º 4
0
        static public PluginHost Create()
        {
            var builder = new System.ComponentModel.Composition.Registration.RegistrationBuilder();

            // addins
            builder
            .ForTypesDerivedFrom <IAddinContract>()
            //.Export<IAddinContract>()
            .ExportInterfaces()
            ;

            // host
            builder
            .ForType <PluginHost>()
            //.ImportProperty(x => x.Addins, b => b.AsMany())
            .Export <PluginHost>()
            ;

            var hostCatalog = new System.ComponentModel.Composition.Hosting.AssemblyCatalog(typeof(PluginHost).Assembly, builder);
            var aCataog     = new System.ComponentModel.Composition.Hosting.AggregateCatalog(hostCatalog);

#if false
            var catalog = new System.ComponentModel.Composition.Hosting.DirectoryCatalog("addins");
            aCataog.Catalogs.Add(catalog);
#else
            foreach (var f in new DirectoryInfo("addins").GetFiles().Where(x => x.Name.ToLower().EndsWith(".dll")))
            {
                var catalog = new System.ComponentModel.Composition.Hosting.AssemblyCatalog(Assembly.LoadFile(f.FullName), builder);
                aCataog.Catalogs.Add(catalog);
            }
#endif

            var container = new System.ComponentModel.Composition.Hosting.CompositionContainer(aCataog);
#if false
            var host = new PluginHost();
            container.ComposeParts(host);
            return(host);
#else
            return(container.GetExportedValue <PluginHost>());
#endif
        }
Ejemplo n.º 5
0
 public Bll()
 { //执行注入
     container.ComposeParts(this);
 }