mirror of
https://github.com/reactos/reactos.git
synced 2024-11-10 00:34:39 +00:00
d7b2077ed8
- 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
51 lines
1.3 KiB
C#
51 lines
1.3 KiB
C#
using System;
|
|
|
|
namespace TechBot.Library
|
|
{
|
|
public abstract class Command
|
|
{
|
|
protected TechBotService m_TechBotService = null;
|
|
protected MessageContext m_Context = null;
|
|
|
|
public TechBotService TechBot
|
|
{
|
|
get { return m_TechBotService; }
|
|
set { m_TechBotService = value; }
|
|
}
|
|
|
|
public MessageContext Context
|
|
{
|
|
get { return m_Context; }
|
|
set { m_Context = value; }
|
|
}
|
|
|
|
public string Name
|
|
{
|
|
get
|
|
{
|
|
CommandAttribute commandAttribute = (CommandAttribute)
|
|
Attribute.GetCustomAttribute(GetType(), typeof(CommandAttribute));
|
|
|
|
return commandAttribute.Name;
|
|
}
|
|
}
|
|
|
|
public void ParseParameters(string paramaters)
|
|
{
|
|
ParametersParser parser = new ParametersParser(paramaters, this);
|
|
parser.Parse();
|
|
}
|
|
|
|
protected virtual void Say(string message)
|
|
{
|
|
TechBot.ServiceOutput.WriteLine(Context, message);
|
|
}
|
|
|
|
protected virtual void Say(string format , params object[] args)
|
|
{
|
|
TechBot.ServiceOutput.WriteLine(Context, String.Format(format, args));
|
|
}
|
|
|
|
public abstract void ExecuteCommand();
|
|
}
|
|
}
|