4 namespace TechBot.Library
6 public class WinerrorCommand : XmlCommand
8 public WinerrorCommand(TechBotService techBot)
13 public override string XmlFile
15 get { return Settings.Default.WinErrorXml; }
18 public override string[] AvailableCommands
20 get { return new string[] { "winerror" }; }
23 public override void Handle(MessageContext context,
27 string winerrorText = parameters;
28 if (winerrorText.Equals(String.Empty))
30 TechBot.ServiceOutput.WriteLine(context,
31 "Please provide a valid System Error Code value.");
35 NumberParser np = new NumberParser();
36 long winerror = np.Parse(winerrorText);
39 TechBot.ServiceOutput.WriteLine(context,
40 String.Format("{0} is not a valid System Error Code value.",
45 string description = GetWinerrorDescription(winerror);
46 if (description != null)
48 TechBot.ServiceOutput.WriteLine(context,
49 String.Format("{0} is {1}.",
55 TechBot.ServiceOutput.WriteLine(context,
56 String.Format("I don't know about System Error Code {0}.",
61 public override string Help()
63 return "!winerror <value>";
66 public string GetWinerrorDescription(long winerror)
68 XmlElement root = base.m_XmlDocument.DocumentElement;
69 XmlNode node = root.SelectSingleNode(String.Format("Winerror[@value='{0}']",
73 XmlAttribute text = node.Attributes["text"];
75 throw new Exception("Node has no text attribute.");