static DocConfig () { const string ManifestResourceName = "DocFood.config.xml"; using (var reader = XmlTextReader.Create (typeof (DocConfig).Assembly.GetManifestResourceStream (ManifestResourceName))) { Instance = Read (reader); } }
static DocConfig() { const string ManifestResourceName = "DocFood.config.xml"; using (var reader = XmlTextReader.Create(typeof(DocConfig).Assembly.GetManifestResourceStream(ManifestResourceName))) { Instance = Read(reader); } }
public static DocConfig Read (XmlReader reader) { DocConfig result = new DocConfig (); XmlReadHelper.ReadList (reader, "DocFood", delegate () { switch (reader.LocalName) { case "WordLists": XmlReadHelper.ReadList (reader, reader.LocalName, delegate () { switch (reader.LocalName) { case "List": string name = reader.GetAttribute ("name"); List<string> words = new List<string> (); XmlReadHelper.ReadList (reader, reader.LocalName, delegate () { switch (reader.LocalName) { case "Word": words.Add (reader.ReadElementString ()); return true; } return false; }); result.WordLists[name] = words; return true; } return false; }); return true; case "WordExpansion": XmlReadHelper.ReadList (reader, reader.LocalName, delegate () { switch (reader.LocalName) { case "Word": result.WordExpansions[reader.GetAttribute ("from")] = reader.GetAttribute ("to"); return true; } return false; }); return true; case "Macros": XmlReadHelper.ReadList (reader, reader.LocalName, delegate () { switch (reader.LocalName) { case "Macro": result.Macros[reader.GetAttribute ("tag")] = reader.GetAttribute ("value"); return true; } return false; }); return true; case "Rules": result.Rules = Node.ReadNodeList (reader, "Rules"); return true; } return false; }); return result; }
public static DocConfig Read(XmlReader reader) { DocConfig result = new DocConfig(); XmlReadHelper.ReadList(reader, "DocFood", delegate() { switch (reader.LocalName) { case "WordLists": XmlReadHelper.ReadList(reader, reader.LocalName, delegate() { switch (reader.LocalName) { case "List": string name = reader.GetAttribute("name"); List <string> words = new List <string> (); XmlReadHelper.ReadList(reader, reader.LocalName, delegate() { switch (reader.LocalName) { case "Word": words.Add(reader.ReadElementString()); return(true); } return(false); }); result.WordLists[name] = words; return(true); } return(false); }); return(true); case "WordExpansion": XmlReadHelper.ReadList(reader, reader.LocalName, delegate() { switch (reader.LocalName) { case "Word": result.WordExpansions[reader.GetAttribute("from")] = reader.GetAttribute("to"); return(true); } return(false); }); return(true); case "Macros": XmlReadHelper.ReadList(reader, reader.LocalName, delegate() { switch (reader.LocalName) { case "Macro": result.Macros[reader.GetAttribute("tag")] = reader.GetAttribute("value"); return(true); } return(false); }); return(true); case "Rules": result.Rules = Node.ReadNodeList(reader, "Rules"); return(true); } return(false); }); return(result); }