mirror of
https://github.com/reactos/reactos.git
synced 2025-06-24 08:20:54 +00:00
- code refactoring
- made more and more easily extensible: * commands automatically loaded from plugins dlls * declarative and automatic command parameter parsing * common code moved to base classes - other fixes svn path=/trunk/; revision=33344
This commit is contained in:
parent
e3407fdd9c
commit
d7b2077ed8
42 changed files with 2263 additions and 1689 deletions
|
@ -1,82 +0,0 @@
|
|||
using System;
|
||||
using System.Xml;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public class WinerrorCommand : XmlCommand
|
||||
{
|
||||
public WinerrorCommand(TechBotService techBot)
|
||||
: base(techBot)
|
||||
{
|
||||
}
|
||||
|
||||
public override string XmlFile
|
||||
{
|
||||
get { return Settings.Default.WinErrorXml; }
|
||||
}
|
||||
|
||||
public override string[] AvailableCommands
|
||||
{
|
||||
get { return new string[] { "winerror" }; }
|
||||
}
|
||||
|
||||
public override void Handle(MessageContext context,
|
||||
string commandName,
|
||||
string parameters)
|
||||
{
|
||||
string winerrorText = parameters;
|
||||
if (winerrorText.Equals(String.Empty))
|
||||
{
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
"Please provide a valid System Error Code value.");
|
||||
return;
|
||||
}
|
||||
|
||||
NumberParser np = new NumberParser();
|
||||
long winerror = np.Parse(winerrorText);
|
||||
if (np.Error)
|
||||
{
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
String.Format("{0} is not a valid System Error Code value.",
|
||||
winerrorText));
|
||||
return;
|
||||
}
|
||||
|
||||
string description = GetWinerrorDescription(winerror);
|
||||
if (description != null)
|
||||
{
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
String.Format("{0} is {1}.",
|
||||
winerrorText,
|
||||
description));
|
||||
}
|
||||
else
|
||||
{
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
String.Format("I don't know about System Error Code {0}.",
|
||||
winerrorText));
|
||||
}
|
||||
}
|
||||
|
||||
public override string Help()
|
||||
{
|
||||
return "!winerror <value>";
|
||||
}
|
||||
|
||||
public string GetWinerrorDescription(long winerror)
|
||||
{
|
||||
XmlElement root = base.m_XmlDocument.DocumentElement;
|
||||
XmlNode node = root.SelectSingleNode(String.Format("Winerror[@value='{0}']",
|
||||
winerror));
|
||||
if (node != null)
|
||||
{
|
||||
XmlAttribute text = node.Attributes["text"];
|
||||
if (text == null)
|
||||
throw new Exception("Node has no text attribute.");
|
||||
return text.Value;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue