当前位置: 首页>>代码示例>>C#>>正文


C# CompositionContainer.SatisfyImportsOnce方法代码示例

本文整理汇总了C#中System.ComponentModel.Composition.Hosting.CompositionContainer.SatisfyImportsOnce方法的典型用法代码示例。如果您正苦于以下问题:C# CompositionContainer.SatisfyImportsOnce方法的具体用法?C# CompositionContainer.SatisfyImportsOnce怎么用?C# CompositionContainer.SatisfyImportsOnce使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.ComponentModel.Composition.Hosting.CompositionContainer的用法示例。


在下文中一共展示了CompositionContainer.SatisfyImportsOnce方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LoadPlugins

		void LoadPlugins() {
			try{
				var pluginsPath = Utils.MapPath("~/plugins");
				if (!Directory.Exists(pluginsPath)) {
					plugins = Enumerable.Empty<IPlugin>();
					return;
				}
				var catalog = new DirectoryCatalog(pluginsPath);
				var container = new CompositionContainer(catalog);
				container.SatisfyImportsOnce(this);
			} catch (Exception err) {
				//swallow error
				log.WriteError(String.Format("error during loading plugins: {0}", err.Message));
				dbg.Break();
				plugins = Enumerable.Empty<IPlugin>();
			}
			foreach (var p in plugins) {
				try {
					p.Init();
				} catch (Exception err) {
					//swallow error
					log.WriteError(String.Format("error during plugin initialization: {0}", err.Message));
					dbg.Break();
				}
			}
		}
开发者ID:zzilla,项目名称:ONVIF-Device-Manager,代码行数:26,代码来源:App.xaml.cs

示例2: InitializePlugins

    private void InitializePlugins()
    {
      // We look for plugins in our own assembly and in any DLLs that live next to our EXE.
      // We could force all plugins to be in a "Plugins" directory, but it seems more straightforward
      // to just leave everything in one directory
      var builtinPlugins = new AssemblyCatalog(GetType().Assembly);
      var externalPlugins = new DirectoryCatalog(AppDomain.CurrentDomain.BaseDirectory, "*.dll");
      
      _catalog = new AggregateCatalog(builtinPlugins, externalPlugins);
      _container = new CompositionContainer(_catalog);

      try
      {
        _container.SatisfyImportsOnce(this);       
      }
      catch (CompositionException ex)
      {
        if (_log.IsErrorEnabled)
        {
          _log.ErrorFormat("MEF Composition Exception: {0}", ex.Message);

          var errors = String.Join("\n    ", ex.Errors.Select(x => x.Description));
          _log.ErrorFormat("Composition Errors: {0}", errors);
        }
        throw;
      }
    }
开发者ID:BookSwapSteve,项目名称:statsd.net,代码行数:27,代码来源:StatsdnetConfiguration.cs

示例3: OnStartup

        protected override void OnStartup( StartupEventArgs e )
        {
            base.OnStartup( e );

            new UnhandledExceptionHook( this );

            Application.Current.Exit += OnShutdown;

            var catalog = new AssemblyCatalog( GetType().Assembly );
            myContainer = new CompositionContainer( catalog, CompositionOptions.DisableSilentRejection );

            myContainer.Compose( new CompositionBatch() );

            var shell = myContainer.GetExportedValue<Shell>();

            myContainer.SatisfyImportsOnce( shell.myDesigner );

            ( ( Shell )MainWindow ).myProperties.DataContext = shell.myDesigner.SelectionService;

            Application.Current.MainWindow = shell;
            Application.Current.MainWindow.Show();

            var args = Environment.GetCommandLineArgs();
            if( args.Length == 2 )
            {
                shell.myDesigner.Open( args[ 1 ] );
            }
        }
开发者ID:JackWangCUMT,项目名称:Plainion.Whiteboard,代码行数:28,代码来源:App.xaml.cs

示例4: Configure

        /// <summary>
        /// MEF Bootstrap (MEF comes from System.ComponentModel.Composition in the GAC).
        /// <para>This will return a class containing all the application's aggregate roots.</para>
        /// </summary>
        public static ComposedDemoProgram Configure(params string[] pluginDirectories)
        {
            var catalogues = 
                pluginDirectories.Select<string, ComposablePartCatalog>(d=>new DirectoryCatalog(d)).
                Concat(new []{new AssemblyCatalog(Assembly.GetExecutingAssembly())}).ToList();

            var catalog = new AggregateCatalog(catalogues);
            try
            {
                var container = new CompositionContainer(catalog);

                var composedProgram = new ComposedDemoProgram();
                container.SatisfyImportsOnce(composedProgram);

                return composedProgram;
            }
            finally
            {
                catalog.Dispose();
                foreach (var cat in catalogues)
                {
                    cat.Dispose();
                }
            }
        }
开发者ID:mind0n,项目名称:hive,代码行数:29,代码来源:Program.cs

示例5: ComposeWithTypesExportedFromPythonAndCSharp

        public void ComposeWithTypesExportedFromPythonAndCSharp(
            object compositionTarget,
            string scriptsToImport,
            params Type[] typesToImport)
        {
            ScriptSource script;
            var engine = Python.CreateEngine();
            using (var scriptStream = GetType().Assembly.
                GetManifestResourceStream(GetType(), scriptsToImport))
            using (var scriptText = new StreamReader(scriptStream))
            {
                script = engine.CreateScriptSourceFromString(scriptText.ReadToEnd());
            }

            var typeExtractor = new ExtractTypesFromScript(engine);
            var exports = typeExtractor.GetPartsFromScript(script, typesToImport).ToList();

            var catalog = new AssemblyCatalog(Assembly.GetExecutingAssembly());

            var container = new CompositionContainer(catalog);
            var batch = new CompositionBatch(exports, new ComposablePart[] { });
            container.Compose(batch);

            container.SatisfyImportsOnce(compositionTarget);
        }
开发者ID:orthros,项目名称:IronPythonMef,代码行数:25,代码来源:CompositionHelper.cs

示例6: Compose

 private void Compose()
 {
     var path = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
     var catalog = new DirectoryCatalog(path);
     _container = new CompositionContainer(catalog);
     _container.SatisfyImportsOnce(this);
 }
开发者ID:nagyistoce,项目名称:ArchitectureCampSample,代码行数:7,代码来源:ModuleDiscoveryService.cs

示例7: DocumentCache

        internal DocumentCache(string documentDirectoryPath, string templateDirectoryPath, TimeSpan documentLifespan)
        {
            if (!Directory.Exists(documentDirectoryPath))
            {
                throw new DirectoryNotFoundException("Could not find the document directory at \"" + documentDirectoryPath + "\".");
            }

            if (!Directory.Exists(templateDirectoryPath))
            {
                throw new DirectoryNotFoundException("Could not find the template directory at \"" + templateDirectoryPath + "\".");
            }

            this.documentDirectoryPath = documentDirectoryPath;
            this.templateDirectoryPath = templateDirectoryPath;
            this.DocumentLifespan = documentLifespan;

            var catalog = new DirectoryCatalog(templateDirectoryPath);
            var container = new CompositionContainer(catalog);
            container.SatisfyImportsOnce(this);

            if (this.DocumentTemplates.Length == 0)
            {
                throw new ArgumentException("Could not find any templates in the provided directory.", "templateDirectoryPath");
            }

            var pdfDocuments = Directory.GetFiles(documentDirectoryPath, "*.pdf");
            foreach (var document in pdfDocuments)
            {
                var base64Hash = Path.GetFileNameWithoutExtension(document);
                var hash = GetHashArray(base64Hash);
                this.cachedDocuments.TryAdd(hash, new CachedDocument(document));
            }
        }
开发者ID:CrabwiseStudios,项目名称:PDF-Server,代码行数:33,代码来源:DocumentCache.cs

示例8: Initialize

    public static IContainer Initialize(CompositionContainer container, bool resetSingleton)
    {
      Bootstrap bootStrap;

      lock (_lockObject)
      { //  only work on bootstrap instance in one thread at a time
        if (resetSingleton || _instance == null)
        { //  create and MEF initialize the bootstrap object
          bootStrap = new Bootstrap();
          container.SatisfyImportsOnce(bootStrap);
          //  store in singleton
          _instance = bootStrap;
        }
        //  use current instance
        bootStrap = _instance;
      }

      //  now initialize autofac
      ContainerBuilder builder = new ContainerBuilder();
      
      //  add support for implicit collections
      builder.RegisterModule(new Autofac.Modules.ImplicitCollectionSupportModule());
      
      //  add all MEF-ed modules
      foreach (Module module in bootStrap.Modules)
        builder.RegisterModule(module);

      //  create the container
      return builder.Build();
    }
开发者ID:dbuksbaum,项目名称:Hazware.Samples,代码行数:30,代码来源:Bootstrap.cs

示例9: ModuleService

 public ModuleService()
 {
     var path = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
     var catalog = new DirectoryCatalog(path);
     _container = new CompositionContainer(catalog);
     _container.SatisfyImportsOnce(this);
 }
开发者ID:ChristianWeyer,项目名称:ArchitectureCampLive,代码行数:7,代码来源:ModuleService.cs

示例10: InitializeMEF

 private void InitializeMEF()
 {
     CompositionContainer container = new CompositionContainer(new AssemblyCatalog(GetType().Assembly));
     CompositionBatch batch = new CompositionBatch();
     batch.AddExportedValue(container);
     container.Compose(batch);
     container.SatisfyImportsOnce(this);
 }
开发者ID:Beerman006,项目名称:timetracker,代码行数:8,代码来源:App.xaml.cs

示例11: Application_Start

 protected virtual void Application_Start(Object sender, EventArgs e)
 {
     DirectoryCatalog dirCatalog = new DirectoryCatalog(Server.MapPath("bin"),"*.dll");
     AssemblyCatalog asCatalog = new AssemblyCatalog(this.GetType().Assembly);
     AggregateCatalog catalog = new AggregateCatalog(dirCatalog,asCatalog);
     CompositionContainer container = new CompositionContainer(catalog);
     container.SatisfyImportsOnce(this);
 }
开发者ID:jimmy00784,项目名称:MEFExample,代码行数:8,代码来源:Global.asax.cs

示例12: DataManService

 public DataManService()
 {
   var catalog = new AggregateCatalog();
   catalog.Catalogs.Add(new AssemblyCatalog(Assembly.GetExecutingAssembly()));
   catalog.Catalogs.Add(new AssemblyCatalog(typeof(IData).Assembly));
   _container = new CompositionContainer(catalog);
   _container.SatisfyImportsOnce(this);
   _data = Data;
 }
开发者ID:lucmig,项目名称:mint,代码行数:9,代码来源:DataManService.cs

示例13: Setup

        public void Setup()
        {
            // See notes in TrailTest class about wiring up the repository
            DirectoryCatalog repositoryCatalog = new DirectoryCatalog(@".\PlugIns");
            _repositoryFactory = new RepositoryFactory();

            // Now, set up the MEF container and use it to hydrate the _repositoryFactory object
            _container = new CompositionContainer(repositoryCatalog);
            _container.SatisfyImportsOnce(_repositoryFactory);
        }
开发者ID:andy-thomas,项目名称:Trails2010,代码行数:10,代码来源:TrailIntegrationTests.cs

示例14: Translate

            /// <summary>
            /// Translate an expression.
            /// </summary>
            /// <param name="expr"></param>
            /// <param name="cc"></param>
            /// <returns></returns>
            public static Expression Translate(Expression expr, IGeneratedQueryCode gc, ICodeContext cc, CompositionContainer container)
            {
                var tr = new ResolveToExpression() { CodeContext = cc, GeneratedCode = gc, MEFContainer = container };
                if (container != null)
                {
                    container.SatisfyImportsOnce(tr);
                }

                return tr.Visit(expr);
            }
开发者ID:gordonwatts,项目名称:LINQtoROOT,代码行数:16,代码来源:ExpressionResolver.cs

示例15: Initialize

        public void Initialize()
        {
            if (Plugins == null)
            {
                // MEF loading of available plug-ins
                var catalog = new DirectoryCatalog(".", "UUM.Plugin.*.dll");
                var container = new CompositionContainer(catalog);

                container.SatisfyImportsOnce(this);
            }
        }
开发者ID:Ahmadlabib2,项目名称:Universal-User-Manager,代码行数:11,代码来源:PluginRepository.cs


注:本文中的System.ComponentModel.Composition.Hosting.CompositionContainer.SatisfyImportsOnce方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。