Пример #1
0
 public static void LoadContainer(
     ApplicationParameters parameters, IUnityContainer container, string path, string pattern)
 {
     var importDef = BuildImportDefinition();
     using (var dirCat = new DirectoryCatalog(path, pattern))
     using (var aggregateCatalog = new AggregateCatalog())
     {
         aggregateCatalog.Catalogs.Add(dirCat);
         using (var componsitionContainer = new CompositionContainer(aggregateCatalog))
         {
             var modules = componsitionContainer.GetExports(importDef).Select(e => e.Value).OfType<IModule>();
             var registrar = new ModuleRegistrar(container);
             foreach (var module in modules)
             {
                 module.Initialize(parameters, registrar);
             }
         }
     }
 }
Пример #2
0
        public static void LoadContainer(
            ApplicationParameters parameters, IUnityContainer container, string path, string pattern)
        {
            var importDef = BuildImportDefinition();

            using (var dirCat = new DirectoryCatalog(path, pattern))
                using (var aggregateCatalog = new AggregateCatalog())
                {
                    aggregateCatalog.Catalogs.Add(dirCat);
                    using (var componsitionContainer = new CompositionContainer(aggregateCatalog))
                    {
                        var modules   = componsitionContainer.GetExports(importDef).Select(e => e.Value).OfType <IModule>();
                        var registrar = new ModuleRegistrar(container);
                        foreach (var module in modules)
                        {
                            module.Initialize(parameters, registrar);
                        }
                    }
                }
        }