4 namespace TechBot.Library
6 [Command("winerror", Help = "!winerror <value>")]
7 public class WinErrorCommand : XmlLookupCommand
9 public WinErrorCommand()
13 public override string XmlFile
15 get { return Settings.Default.WinErrorXml; }
18 public override void ExecuteCommand()
20 if (Text.Equals(String.Empty))
22 TechBot.ServiceOutput.WriteLine(Context,
23 "Please provide a valid System Error Code value.");
27 NumberParser np = new NumberParser();
28 long winerror = np.Parse(Text);
31 TechBot.ServiceOutput.WriteLine(Context,
32 String.Format("{0} is not a valid System Error Code value.",
37 string description = GetWinerrorDescription(winerror);
38 if (description != null)
40 TechBot.ServiceOutput.WriteLine(Context,
41 String.Format("{0} is {1}.",
47 TechBot.ServiceOutput.WriteLine(Context,
48 String.Format("I don't know about System Error Code {0}.",
53 public string GetWinerrorDescription(long winerror)
55 XmlElement root = base.m_XmlDocument.DocumentElement;
56 XmlNode node = root.SelectSingleNode(String.Format("Winerror[@value='{0}']",
60 XmlAttribute text = node.Attributes["text"];
62 throw new Exception("Node has no text attribute.");