Пример #1
0
        public IRuntimePluginLoader <T> Create <TRuntimePluginLoader, T>(params object[] dependencies)
            where TRuntimePluginLoader : class, IRuntimePluginLoader <T>
        {
            if (Singletons == null)
            {
                Singletons = new SingletonObjects();
            }
            var typeLoader         = new TypeLoader <T>(Singletons.Settings, Singletons.Logger);
            var pluginCacheFactory = new PluginCacheFactory <T>(typeLoader,
                                                                Singletons.PluginDependencyResolverFactory,
                                                                Singletons.AssemblyLoader,
                                                                Singletons.Logger);
            var pluginLoaderFactory = new PluginLoaderFactory <T>(pluginCacheFactory);
            var pluginObjectCreator = new PluginObjectCreator <T>(Singletons.Settings, new ObjectCreator <T>(), Singletons.Logger);
            IRuntimePluginLoader <T> runtimePluginLoader = (dependencies == null || !dependencies.Any())
                ? Activator.CreateInstance(typeof(TRuntimePluginLoader),
                                           Singletons.AppDomain,
                                           Singletons.Settings,
                                           pluginLoaderFactory,
                                           pluginObjectCreator,
                                           Singletons.PluginPaths,
                                           Singletons.Logger) as IRuntimePluginLoader <T>
                : Activator.CreateInstance(typeof(TRuntimePluginLoader),
                                           Singletons.AppDomain,
                                           Singletons.Settings,
                                           pluginLoaderFactory,
                                           pluginObjectCreator,
                                           Singletons.PluginPaths,
                                           Singletons.Logger,
                                           dependencies) as IRuntimePluginLoader <T>;

            return(runtimePluginLoader);
        }