温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:IFNuke1.1.0版源码
当前文件:
IFnuke110/Core/ProviderConfiguration.cs,打开代码结构图
IFnuke110/Core/ProviderConfiguration.cs,打开代码结构图1using System; 2
using System.IO; 3
using System.Collections; 4
using System.Collections.Specialized; 5
using System.Configuration; 6
using System.Xml; 7
8
namespace IFNuke 9
{ 10
public class ProviderConfiguration 11
{ 12
private string _defaultProvider; 13
private Hashtable _providers = new Hashtable(); 14
15
public string DefaultProvider 16
{ 17
get { return _defaultProvider; } 18
} 19
public Hashtable Providers 20
{ 21
get { return _providers; } 22
} 23
24
public static ProviderConfiguration GetProviderConfiguration(string providerConfigurationSection) 25
{ 26
XmlNode node = Config.GetProviderConfigurationSection(providerConfigurationSection); 27
ProviderConfiguration pc = new ProviderConfiguration(); 28
pc.LoadValuesFromConfigurationXml(node); 29
return pc; 30
} 31
32
private void LoadValuesFromConfigurationXml(XmlNode node) 33
{ 34
XmlAttributeCollection attributes = node.Attributes; 35
_defaultProvider = attributes["defaultProvider"].Value; 36
37
// Read child nodes 38
foreach (XmlNode child in node.ChildNodes) 39
{ 40
if (child.Name == "providers") 41
GetProviders(child); 42
} 43
} 44
45
private void GetProviders(XmlNode node) 46
{ 47
foreach (XmlNode childNode in node.ChildNodes) 48
{ 49
switch (childNode.Name) 50
{ 51
case "add": 52
_providers.Add(childNode.Attributes["name"].Value, new Provider(childNode.Attributes)); 53
break; 54
case "remove": 55
_providers.Remove(childNode.Attributes["name"].Value); 56
break; 57
case "clear": 58
_providers.Clear(); 59
break; 60
} 61
} 62
} 63
} 64
65
}





}
}