HTML5技术

使用sqlserver搭建高可用双机热备的Quartz集群部署【附源码】 - 一线码农(2)

字号+ 作者:H5之家 来源:H5之家 2017-05-29 13:01 我要评论( )

1 IList string dsNames = cfg.GetPropertyGroups(PropertyDataSourcePrefix); 2 foreach ( string dataSourceName in dsNames) 3 { .FormatInvariant(PropertyDataSourcePrefix, dataSourceName); 5 NameValueColl

1 IList<string> dsNames = cfg.GetPropertyGroups(PropertyDataSourcePrefix); 2 foreach (string dataSourceName in dsNames) 3 { .FormatInvariant(PropertyDataSourcePrefix, dataSourceName); 5 NameValueCollection propertyGroup = cfg.GetPropertyGroup(datasourceKey, true); 6 PropertiesParser pp = new PropertiesParser(propertyGroup); 7 8 Type cpType = loadHelper.LoadType(pp.GetStringProperty(PropertyDbProviderType, null)); (cpType != null) 12 { 13 IDbProvider cp; { 16 cp = ObjectUtils.InstantiateType<IDbProvider>(cpType); 17 } 18 catch (Exception e) 19 { .FormatInvariant(cpType), e); 21 throw initException; 22 } { pp.UnderlyingProperties.Remove(PropertyDbProviderType); 28 29 ObjectUtils.SetObjectProperties(cp, pp.UnderlyingProperties); 30 cp.Initialize(); 31 } 32 catch (Exception e) 33 { .FormatInvariant(cpType), e); 35 throw initException; 36 } 37 38 dbMgr = DBConnectionManager.Instance; 39 dbMgr.AddConnectionProvider(dataSourceName, cp); 40 } { 43 string dsProvider = pp.GetStringProperty(PropertyDataSourceProvider, null); 44 string dsConnectionString = pp.GetStringProperty(PropertyDataSourceConnectionString, null); 45 string dsConnectionStringName = pp.GetStringProperty(PropertyDataSourceConnectionStringName, null); (dsConnectionString == null && !String.IsNullOrEmpty(dsConnectionStringName)) 48 { 49 50 ConnectionStringSettings connectionStringSettings = ConfigurationManager.ConnectionStrings[dsConnectionStringName]; 51 if (connectionStringSettings == null) 52 { .FormatInvariant(dsConnectionStringName, dataSourceName)); 54 throw initException; 55 } 56 dsConnectionString = connectionStringSettings.ConnectionString; 57 } (dsProvider == null) 60 { .FormatInvariant(dataSourceName)); 62 throw initException; 63 } 64 if (dsConnectionString == null) 65 { .FormatInvariant(dataSourceName)); 67 throw initException; 68 } { 71 DbProvider dbp = new DbProvider(dsProvider, dsConnectionString); 72 dbp.Initialize(); 73 74 dbMgr = DBConnectionManager.Instance; 75 dbMgr.AddConnectionProvider(dataSourceName, dbp); 76 } 77 catch (Exception exception) 78 { .FormatInvariant(dataSourceName), exception); 80 throw initException; 81 } 82 } 83 }

 

     接下来的问题就是这几个属性是如何配置进去的,仔细观察上面代码,你会发现所有的配置的源头都来自于cfg变量,ok,接下来你可以继续翻看代码,相信

你会看到有一个Initialize方法就是做cfg变量的初始化,如下代码所示:

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • localstorage和sessionstorage上手使用记录 - 蓓蕾心晴

    localstorage和sessionstorage上手使用记录 - 蓓蕾心晴

    2017-05-24 09:00

  • TensorFlowSharp入门使用C#编写TensorFlow人工智能应用 - LineZero

    TensorFlowSharp入门使用C#编写TensorFlow人工智能应用 - LineZero

    2017-05-24 08:00

  • .net 企业管理系统快速搭建框架 - 请求

    .net 企业管理系统快速搭建框架 - 请求

    2017-05-22 18:06

  • 使用three.js实现机器人手臂的运动效果 - faker_archer

    使用three.js实现机器人手臂的运动效果 - faker_archer

    2017-05-21 14:02

网友点评
n