Beispiel #1
0
        static ChatHandler()
        {
            ChatCommands = new List <IChatCommand>();

            List <Type> allCommandTypes = ChatCommandAttribute.GetAllUsingTypes(
                Assembly.GetAssembly(typeof(ChatHandler)));

            foreach (Type t in allCommandTypes)
            {
                IChatCommand cmd = Activator.CreateInstance(t) as IChatCommand;

                if (cmd != null)
                {
                    ChatCommands.Add(cmd);
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("[ERROR]: Chat command type does not inherit from IChatCommand: " + t.Name);
                }
            }
        }