mirror of
https://github.com/reactos/reactos.git
synced 2026-05-30 23:33:24 +08:00
* refactor the code to make it more OOP and extensible
* remove old outdated SD project files * make it use some .NET 2.0 features as generic collections and settings svn path=/trunk/; revision=31130
This commit is contained in:
@@ -4,30 +4,32 @@ using System.Collections;
|
||||
|
||||
namespace TechBot.Library
|
||||
{
|
||||
public class ErrorCommand : BaseCommand, ICommand
|
||||
public class ErrorCommand : Command
|
||||
{
|
||||
private IServiceOutput serviceOutput;
|
||||
private NtStatusCommand ntStatus;
|
||||
private WinerrorCommand winerror;
|
||||
private HresultCommand hresult;
|
||||
private HResultCommand hresult;
|
||||
|
||||
public ErrorCommand(IServiceOutput serviceOutput, string ntstatusXml,
|
||||
string winerrorXml, string hresultXml)
|
||||
public ErrorCommand(TechBotService techBot)
|
||||
: base(techBot)
|
||||
{
|
||||
this.serviceOutput = serviceOutput;
|
||||
this.ntStatus = new NtStatusCommand(serviceOutput,
|
||||
ntstatusXml);
|
||||
this.winerror = new WinerrorCommand(serviceOutput,
|
||||
winerrorXml);
|
||||
this.hresult = new HresultCommand(serviceOutput,
|
||||
hresultXml);
|
||||
this.ntStatus = new NtStatusCommand(techBot);
|
||||
this.winerror = new WinerrorCommand(techBot);
|
||||
this.hresult = new HResultCommand(techBot);
|
||||
}
|
||||
|
||||
/*
|
||||
public bool CanHandle(string commandName)
|
||||
{
|
||||
return CanHandle(commandName,
|
||||
new string[] { "error" });
|
||||
}
|
||||
*/
|
||||
|
||||
public override string[] AvailableCommands
|
||||
{
|
||||
get { return new string[] { "error" }; }
|
||||
}
|
||||
|
||||
private static int GetSeverity(long error)
|
||||
{
|
||||
@@ -79,14 +81,14 @@ namespace TechBot.Library
|
||||
return code.ToString();
|
||||
}
|
||||
|
||||
public void Handle(MessageContext context,
|
||||
public override void Handle(MessageContext context,
|
||||
string commandName,
|
||||
string parameters)
|
||||
{
|
||||
string originalErrorText = parameters.Trim();
|
||||
if (originalErrorText.Equals(String.Empty))
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
"Please provide an Error Code.");
|
||||
return;
|
||||
}
|
||||
@@ -98,7 +100,7 @@ namespace TechBot.Library
|
||||
long error = np.Parse(errorText);
|
||||
if (np.Error)
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
String.Format("{0} is not a valid Error Code.",
|
||||
originalErrorText));
|
||||
return;
|
||||
@@ -173,30 +175,30 @@ namespace TechBot.Library
|
||||
goto retry;
|
||||
}
|
||||
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
String.Format("I don't know about Error Code {0}.",
|
||||
originalErrorText));
|
||||
}
|
||||
else if (descriptions.Count == 1)
|
||||
{
|
||||
string description = (string)descriptions[0];
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
String.Format("{0} is {1}.",
|
||||
originalErrorText,
|
||||
description));
|
||||
}
|
||||
else
|
||||
{
|
||||
serviceOutput.WriteLine(context,
|
||||
TechBot.ServiceOutput.WriteLine(context,
|
||||
String.Format("{0} could be:",
|
||||
originalErrorText));
|
||||
|
||||
foreach(string description in descriptions)
|
||||
serviceOutput.WriteLine(context, String.Format("\t{0}", description));
|
||||
TechBot.ServiceOutput.WriteLine(context, String.Format("\t{0}", description));
|
||||
}
|
||||
}
|
||||
|
||||
public string Help()
|
||||
|
||||
public override string Help()
|
||||
{
|
||||
return "!error <value>";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user