本文整理汇总了C#中Configuration.LoadConfiguration方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.LoadConfiguration方法的具体用法?C# Configuration.LoadConfiguration怎么用?C# Configuration.LoadConfiguration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Configuration
的用法示例。
在下文中一共展示了Configuration.LoadConfiguration方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadConfiguration
public static void LoadConfiguration()
{
if (!File.Exists("config.txt"))
throw new Exception("Unable to find the file 'config.txt' !");
_config = new Configuration();
_config.LoadConfiguration();
}
示例2: LoadConfiguration
public static void LoadConfiguration()
{
if (!System.IO.File.Exists("DofusOrigin.conf"))
throw new Exception("Configuration file doesn't exist !");
_config = new Configuration();
_config.LoadConfiguration("DofusOrigin.conf");
}
示例3: Configure
public void Configure(Configuration.IConfigurationProvider configProvider, bool merge = false)
{
if (merge)
{
var configToMerge = configProvider.LoadConfiguration();
var currentConfig = GetConfiguration();
// todo: merge all
foreach(var filter in configToMerge.GlobalFilters)
{
if (filter is LazyFilterReference)
{
var resolvedFilter =
(from f in currentConfig.FilterDefinitions
where f.Name == filter.Name
select f).FirstOrDefault();
currentConfig.GlobalFilters.Add(resolvedFilter);
}
}
foreach (var sink in configToMerge.Sinks)
{
if (sink is EmailSink)
((EmailSink)sink).BodyFormatter = currentConfig.Formatters.Where(f => f.Name == "generic").FirstOrDefault();
if(sink.Filter != null && sink.Filter is LazyFilterReference)
{
sink.Filter =
(from f in currentConfig.FilterDefinitions
where f.Name == sink.Filter.Name
select f).FirstOrDefault();
}
currentConfig.SinkDefinitions.Add(sink);
}
foreach (var sink in configToMerge.Sinks)
currentConfig.Sinks.Add(sink);
Configure(currentConfig);
}
else
{
Configure(configProvider.LoadConfiguration());
}
}