示例#1
0
 /// <summary>
 /// 初始化一个新的<see cref="OSharpConfig"/>实例
 /// </summary>
 private OSharpConfig()
 {
     OSharpFrameworkSection section = (OSharpFrameworkSection)ConfigurationManager.GetSection(OSharpSectionName);
     if (section == null)
     {
         DataConfig = new DataConfig();
         LoggingConfig = new LoggingConfig();
         return;
     }
     DataConfig = new DataConfig(section.Data);
     LoggingConfig = new LoggingConfig(section.Logging);
 }
示例#2
0
        /// <summary>
        /// 初始化一个新的<see cref="OSharpConfig"/>实例
        /// </summary>
        private OSharpConfig()
        {
            OSharpFrameworkSection section = (OSharpFrameworkSection)ConfigurationManager.GetSection(OSharpSectionName);

            if (section == null)
            {
                DataConfig    = new DataConfig();
                LoggingConfig = new LoggingConfig();
                return;
            }
            DataConfig    = new DataConfig(section.Data);
            LoggingConfig = new LoggingConfig(section.Logging);
        }
示例#3
0
 /// <summary>
 /// 重置数据配置信息
 /// </summary>
 /// <param name="config">原始数据配置信息</param>
 /// <returns>重置后的数据配置信息</returns>
 public DataConfig Reset(DataConfig config)
 {
     //没有上下文,添加默认上下文
     if (!config.ContextConfigs.Any())
     {
         DbContextConfig contextConfig = GetDefaultDbContextConfig();
         config.ContextConfigs.Add(contextConfig);
     }
     //如果业务上下文存在开启数据日志功能,并且日志上下文没有设置,则添加日志上下文
     if (config.ContextConfigs.All(m => m.ContextType != typeof(LoggingDbContext)))
     {
         DbContextConfig contextConfig = GetLoggingDbContextConfig();
         config.ContextConfigs.Add(contextConfig);
     }
     return config;
 }
示例#4
0
 /// <summary>
 /// 开始初始化数据库
 /// </summary>
 /// <param name="config">数据库配置信息</param>
 public virtual void Initialize(DataConfig config)
 {
     //没有上下文,添加默认上下文
     if (!config.ContextConfigs.Any())
     {
         DbContextConfig contextConfig = GetDefaultDbContextConfig();
         config.ContextConfigs.Add(contextConfig);
     }
     //如果业务上下文存在开启数据日志功能,并且日志上下文没有设置,则添加日志上下文
     if (config.ContextConfigs.All(m => m.ContextType != typeof(LoggingDbContext)))
     {
         DbContextConfig contextConfig = GetLoggingDbContextConfig();
         config.ContextConfigs.Add(contextConfig);
     }
     foreach (DbContextConfig contextConfig in config.ContextConfigs)
     {
         DbContextInit(contextConfig);
     }
 }