- code refactoring
[reactos.git] / irc / TechBot / TechBot.Library / Commands / Base / Command.cs
1 using System;
2
3 namespace TechBot.Library
4 {
5 public abstract class Command
6 {
7 protected TechBotService m_TechBotService = null;
8 protected MessageContext m_Context = null;
9
10 public TechBotService TechBot
11 {
12 get { return m_TechBotService; }
13 set { m_TechBotService = value; }
14 }
15
16 public MessageContext Context
17 {
18 get { return m_Context; }
19 set { m_Context = value; }
20 }
21
22 public string Name
23 {
24 get
25 {
26 CommandAttribute commandAttribute = (CommandAttribute)
27 Attribute.GetCustomAttribute(GetType(), typeof(CommandAttribute));
28
29 return commandAttribute.Name;
30 }
31 }
32
33 public void ParseParameters(string paramaters)
34 {
35 ParametersParser parser = new ParametersParser(paramaters, this);
36 parser.Parse();
37 }
38
39 protected virtual void Say(string message)
40 {
41 TechBot.ServiceOutput.WriteLine(Context, message);
42 }
43
44 protected virtual void Say(string format , params object[] args)
45 {
46 TechBot.ServiceOutput.WriteLine(Context, String.Format(format, args));
47 }
48
49 public abstract void ExecuteCommand();
50 }
51 }