/// <summary>
        /// 添加服务
        /// </summary>
        /// <param name="service"></param>
        /// <param name="appAction"></param>
        /// <param name="configuration"></param>
        /// <returns></returns>
        public static IServiceCollection AddBrochureCore(this IServiceCollection service, Action <ApplicationOption> appAction = null, IConfiguration configuration = null)
        {
            ObjectConverCollection.RegistObjectConver <IRecord>(t => new Record(t.AsDictionary()));
            //加载一些基本的工具类
            //工具类初始化
            service.TryAddSingleton <IPluginManagers>(new PluginManagers());
            service.TryAddSingleton <IJsonUtil>(new JsonUtil());
            service.TryAddSingleton <IReflectorUtil>(new ReflectorUtil());
            service.TryAddSingleton <IObjectFactory>(new ObjectFactory());
            service.TryAddSingleton <ISysDirectory>(new SysDirectory());
            service.TryAddSingleton <IModuleLoader, ModuleLoader>();
            service.TryAddSingleton <IHostEnvironment, HostingEnvironment>();
            service.AddTransient <IPluginContext, PluginContext>();
            service.TryAddSingleton <IAspectConfiguration, AspectConfiguration>();
            service.AddSingleton <IPluginLoadAction, DefaultLoadAction>();
            service.AddSingleton <IPluginLoader, PluginLoader>();
            service.AddSingleton <IPluginLoadContextProvider, PluginLoadContextProvider>();
            service.AddSingleton <IPluginUnLoadAction, DefaultUnLoadAction>();
            var option = new ApplicationOption(service, configuration);

            appAction?.Invoke(option);
            service.TryAddSingleton(option);
            //加载一些核心的程序
            service.InitApplicationCore();
            return(service);
        }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PluginLoader"/> class.
 /// </summary>
 /// <param name="directory">The directory.</param>
 /// <param name="jsonUtil">The json util.</param>
 /// <param name="pluginLoadContextProvider"></param>
 /// <param name="log">The log.</param>
 /// <param name="reflectorUtil">The reflector util.</param>
 /// <param name="objectFactory">The object factory.</param>
 /// <param name="pluginManagers"></param>
 /// <param name="moduleLoader"></param>
 /// <param name="loadActions"></param>
 /// <param name="unLoadActions"></param>
 /// <param name="applicationOption"></param>
 /// <param name="hostEnvironment"></param>
 public PluginLoader(ISysDirectory directory,
                     IJsonUtil jsonUtil,
                     IPluginLoadContextProvider pluginLoadContextProvider,
                     ILogger <PluginLoader> log,
                     IReflectorUtil reflectorUtil,
                     IObjectFactory objectFactory,
                     IPluginManagers pluginManagers,
                     IModuleLoader moduleLoader,
                     IEnumerable <IPluginLoadAction> loadActions,
                     IEnumerable <IPluginUnLoadAction> unLoadActions,
                     ApplicationOption applicationOption,
                     IHostEnvironment hostEnvironment)
 {
     this.directory = directory;
     this.jsonUtil  = jsonUtil;
     this.pluginLoadContextProvider = pluginLoadContextProvider;
     this.log           = log;
     pluginContextDic   = objectFactory.Create <ConcurrentDictionary <Guid, IPluginsLoadContext> >();
     this.reflectorUtil = reflectorUtil;
     this.objectFactory = objectFactory;
     _pluginManagers    = pluginManagers;
     _moduleLoader      = moduleLoader;
     _loadActions       = loadActions;
     _unLoadActions     = unLoadActions;
     _applicationOption = applicationOption;
     _hostEnvironment   = hostEnvironment;
 }
 /// <summary>
 /// Adds the log.
 /// </summary>
 /// <param name="applicationOption">The application option.</param>
 public static void AddLog(this ApplicationOption applicationOption)
 {
     Log.Logger   = applicationOption.Services.GetServiceInstance <ILoggerFactory> ()?.CreateLogger("Brochure");
     Log.Services = applicationOption.Services;
 }