/// <summary> /// 见基类 /// </summary> public override Configuration Clone() { GameConfiguration ini = new GameConfiguration(base.Name, this.Count); foreach (KeyValuePair <string, ConfigurationSection> e1 in this) { //Dictionary<string, string> newSectData = new Dictionary<string, string>(e1.Value.Count); GameConfigurationSection newSect = new GameConfigurationSection(ini, e1.Key, e1.Value.Count); foreach (KeyValuePair <string, string> e2 in e1.Value) { newSect.Add(e2.Key, e2.Value); } ini.Add(e1.Key, newSect); } return(ini); }
public GameConfiguration(string file) : base(file, EqualityComparer <string> .Default) { XmlTextReader xml = new XmlTextReader(File.Open(file, FileMode.Open, FileAccess.Read)); xml.WhitespaceHandling = WhitespaceHandling.None; int depth = xml.Depth; GameConfigurationSection currentSection = null; string currentAttrib = string.Empty; while (MoveToNextElement(xml)) { switch (xml.NodeType) { case XmlNodeType.Element: case XmlNodeType.Text: case XmlNodeType.CDATA: switch (xml.Depth) { case 1: currentSection = new GameConfigurationSection(xml.Name); Add(xml.Name, currentSection); break; case 2: currentAttrib = xml.Name; break; case 3: currentSection.Add(currentAttrib, xml.ReadString()); break; } break; } } xml.Close(); }
public GameConfiguration(ResourceLocation fl) : base(fl.Name, EqualityComparer<string>.Default) { XmlTextReader xml = new XmlTextReader(fl.GetStream); xml.WhitespaceHandling = WhitespaceHandling.None; int depth = xml.Depth; GameConfigurationSection currentSection = null; string currentAttrib = string.Empty; while (MoveToNextElement(xml)) { switch (xml.NodeType) { case XmlNodeType.Element: case XmlNodeType.Text: case XmlNodeType.CDATA: switch (xml.Depth) { case 1: currentSection = new GameConfigurationSection(xml.Name); Add(xml.Name, currentSection); break; case 2: currentAttrib = xml.Name; break; case 3: currentSection.Add(currentAttrib, xml.ReadString()); break; } break; } } xml.Close(); }
/// <summary> /// 见基类 /// </summary> public override Configuration Clone() { GameConfiguration ini = new GameConfiguration(base.Name, this.Count); foreach (KeyValuePair<string, ConfigurationSection> e1 in this) { //Dictionary<string, string> newSectData = new Dictionary<string, string>(e1.Value.Count); GameConfigurationSection newSect = new GameConfigurationSection(ini, e1.Key, e1.Value.Count); foreach (KeyValuePair<string, string> e2 in e1.Value) { newSect.Add(e2.Key, e2.Value); } ini.Add(e1.Key, newSect); } return ini; }