- code refactoring
[reactos.git] / irc / TechBot / TechBot.Library / Factory / CommandBuilder.cs
1 using System;
2 using System.Reflection;
3 using System.Collections.Generic;
4 using System.Text;
5
6 namespace TechBot.Library
7 {
8 public class CommandBuilder
9 {
10 private Type m_CommandType;
11 private string m_CommandName;
12 private string m_CommandHelp;
13 private string m_CommandDesc;
14
15 public CommandBuilder(Type commandType)
16 {
17 m_CommandType = commandType;
18
19 CommandAttribute commandAttribute = (CommandAttribute)
20 Attribute.GetCustomAttribute(commandType, typeof(CommandAttribute));
21
22 m_CommandName = commandAttribute.Name;
23 m_CommandHelp = commandAttribute.Help;
24 m_CommandDesc = commandAttribute.Description;
25 }
26
27 public string Name
28 {
29 get { return m_CommandName; }
30 }
31
32 public string Help
33 {
34 get { return m_CommandHelp; }
35 }
36
37 public string Description
38 {
39 get { return m_CommandDesc; }
40 }
41
42 public Type Type
43 {
44 get { return m_CommandType; }
45 }
46
47 public Command CreateCommand()
48 {
49 return (Command)Type.Assembly.CreateInstance(Type.FullName, true);
50 }
51 }
52 }