本文整理汇总了C#中IConfigurationProvider.Create方法的典型用法代码示例。如果您正苦于以下问题:C# IConfigurationProvider.Create方法的具体用法?C# IConfigurationProvider.Create怎么用?C# IConfigurationProvider.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IConfigurationProvider
的用法示例。
在下文中一共展示了IConfigurationProvider.Create方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Config
public static Factory Config(IConfigurationProvider provider, Func<string, IDbConnection> connectionConstructor)
{
// set the conguration information
var config = provider.Create();
Current._configuration = config;
// load the dispatcher type for intialization
var dispatcherName = config.Dispatcher;
var dispatcherType = Type
.GetType(config.Dispatchers.Where(dsp => dsp.Name == dispatcherName).First().Type)
.MakeGenericType(typeof(DataSharding));
// load the policies and the related database connection strings
foreach (var policy in config.Policies)
{
var dispatcherKey = policy.Version;
var databases = policy.Nodes.Split(';')
.Select((node) =>
config.Databases
.Where(db => db.Name == node)
.FirstOrDefault())
.ToList();
Current._dispachers.Add(dispatcherKey, CreateDispatcher(dispatcherType, databases));
}
// load the currently version provider
var versionProviderName = config.VersionProvider;
var versionProviderType = Type
.GetType(config.VersionProviders.Where(vp => vp.Name == versionProviderName).First().Type);
Current._versionProvider = Activator.CreateInstance(versionProviderType) as IVersionProvider;
Current._versionProvider.CurrentVersion = config.Version;
// set the other properties
Current._retries = config.Retries;
Current._connectionConstructor = connectionConstructor;
// return the singleton instance
return Current;
}