3 using System.Collections;
4 using System.Collections.Generic;
5 using System.ComponentModel;
6 using System.Reflection;
8 namespace TechBot.Library
10 public class CommandFactory
12 private static CommandBuilderCollection m_Commands = new CommandBuilderCollection();
14 private CommandFactory()
18 public static void LoadPlugins()
20 //get the file names of the dll files in the current directory.
21 FileInfo objExeInfo = new FileInfo(@"C:\Ros\current\irc\TechBot\TechBot.Console\bin\Debug\");
23 foreach (FileInfo objInfo in objExeInfo.Directory.GetFiles("*.dll"))
25 LoadPluginsFromDLLFile(objInfo.FullName);
29 private static void LoadPluginsFromDLLFile(string sFile)
31 Assembly assPlugin = Assembly.LoadFile(sFile);
33 if (assPlugin != null)
35 foreach (Type pluginType in assPlugin.GetTypes())
37 if (pluginType.IsSubclassOf(typeof(Command)))
39 if (pluginType.IsAbstract == false)
42 Commands.Add(new CommandBuilder(pluginType));
49 public static CommandBuilderCollection Commands
51 get { return m_Commands; }