6 namespace TechBot.Commands.Common
8 [Command("winerror", Help = "!winerror <value>")]
9 public class WinErrorCommand : XmlLookupCommand
11 public WinErrorCommand()
15 public override string XmlFile
17 get { return Settings.Default.WinErrorXml; }
20 public override void ExecuteCommand()
22 if (string.IsNullOrEmpty(Text))
24 Say("Please provide a valid System Error Code value.");
28 NumberParser np = new NumberParser();
29 long winerror = np.Parse(Text);
32 Say("{0} is not a valid System Error Code value.", Text);
36 string description = GetWinerrorDescription(winerror);
37 if (description != null)
45 Say("I don't know about System Error Code {0}.", Text);
50 public string GetWinerrorDescription(long winerror)
52 XmlElement root = base.m_XmlDocument.DocumentElement;
53 XmlNode node = root.SelectSingleNode(String.Format("Winerror[@value='{0}']",
54 winerror.ToString()));
57 XmlAttribute text = node.Attributes["text"];
59 throw new Exception("Node has no text attribute.");