示例#1
0
        private static void LoadOneProvider(
            ICatalogLog log,
            string codebase,
            AggregateCatalog catalog
            )
        {
            AssemblyCatalog assemblyCatalog = null;

            const string FailedToLoadAssemblyMessage = "Failed to load interpreter provider assembly {0} {1}";

            try {
                assemblyCatalog = new AssemblyCatalog(codebase);
            } catch (Exception ex) {
                log.Log(String.Format(FailedToLoadAssemblyMessage, codebase, ex));
            }

            if (assemblyCatalog == null)
            {
                return;
            }

            const string FailedToLoadMessage = "Failed to load interpreter provider {0} {1}";

            try {
                catalog.Catalogs.Add(assemblyCatalog);
            } catch (Exception ex) {
                log.Log(String.Format(FailedToLoadMessage, codebase, ex));
            }
        }
示例#2
0
        private static void LoadOneProvider(
            ICatalogLog log,
            string codebase,
            AggregateCatalog catalog
        ) {

            AssemblyCatalog assemblyCatalog = null;

            const string FailedToLoadAssemblyMessage = "Failed to load interpreter provider assembly {0} {1}";
            try {
                assemblyCatalog = new AssemblyCatalog(codebase);
            } catch (Exception ex) {
                log.Log(String.Format(FailedToLoadAssemblyMessage, codebase, ex));
            }

            if (assemblyCatalog == null) {
                return;
            }

            const string FailedToLoadMessage = "Failed to load interpreter provider {0} {1}";
            try {
                catalog.Catalogs.Add(assemblyCatalog);
            } catch (Exception ex) {
                log.Log(String.Format(FailedToLoadMessage, codebase, ex));
            }
        }
示例#3
0
        private static CompositionContainer CreateCatelog(ICatalogLog log, IEnumerable <string> asms)
        {
            var catalog = new AggregateCatalog();

            foreach (var codeBase in asms)
            {
                LoadOneProvider(
                    log,
                    codeBase,
                    catalog
                    );
            }

            return(new CompositionContainer(catalog));
        }
示例#4
0
 public static CompositionContainer CreateContainer(ICatalogLog log, params string[] paths)
 {
     return(CreateCatelog(log, paths));
 }
示例#5
0
 public static CompositionContainer CreateContainer(ICatalogLog log, params Type[] additionalTypes)
 {
     return(CreateContainer(log, GetProviderPaths(additionalTypes).ToArray()));
 }
示例#6
0
 public static CompositionContainer CreateContainer(ICatalogLog log, params string[] paths) {
     return CreateCatelog(log, paths);
 }
示例#7
0
 public static CompositionContainer CreateContainer(ICatalogLog log, params Type[] additionalTypes) {
     return CreateContainer(log, GetProviderPaths(additionalTypes).ToArray());
 }
示例#8
0
        private static CompositionContainer CreateCatelog(ICatalogLog log, IEnumerable<string> asms) {
            var catalog = new AggregateCatalog();
            foreach (var codeBase in asms) {
                LoadOneProvider(
                    log,
                    codeBase,
                    catalog
                );
            }

            return new CompositionContainer(catalog);
        }