/// <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);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DbTest"/> class.
 /// </summary>
 public DbTest()
 {
     transactionManager   = new Mock <TransactionManager>();
     provider             = base.Provider.GetService <IDbProvider>();
     option               = base.Provider.GetService <DbOption>();
     _sqlBuilder          = Provider.GetService <ISqlBuilder>();
     option.IsUseParamers = false;
     ObjectConverCollection.RegistObjectConver <IRecord>(t => new Record(t.AsDictionary()));
 }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AsTest"/> class.
        /// </summary>
        public AsTest()
        {
            var service = new ServiceCollection();

            service.AddLogging();
            service.AddBrochureCore();
            ObjectConverCollection.RegistObjectConver <C, B>(t => new B()
            {
                BStr = "C"
            });
        }