コード例 #1
0
ファイル: CatConsole.cs プロジェクト: LeonXJ/Catsland-XNA
        static public void SearchInAssembly(Assembly _assembly, Dictionary <string, Type> _commandDict)
        {
            Type[] types = _assembly.GetTypes();
            Console.Out.WriteLine("Load console commands class from: " + _assembly.GetName().Name);
            foreach (Type type in types)
            {
                if (type.GetInterface(typeof(IConsoleCommand).Name) != null)
                {
                    Console.WriteLine("- Load class: " + type.Name);

                    ConstructorInfo constructorInfo = type.GetConstructor(new Type[0] {
                    });
                    IConsoleCommand consoleCommend  = constructorInfo.Invoke(new Object[0] {
                    })
                                                      as IConsoleCommand;
                    _commandDict.Add(consoleCommend.GetCommandName(), type);
                }
            }
        }