Example #1
0
 void AddParser(ParserAttribute attribute, MethodInfo method)
 {
     if (!parsers.ContainsKey(attribute.type))
     {
         parsers.Add(attribute.type, method);
     }
     else
     {
         notificationsHandler.NotifyException(new DuplicatedParser(attribute));
     }
 }
Example #2
0
        Command[] GetCommandsInType(Type type)
        {
            List <Command> commands = new List <Command>();

            MethodInfo[] methods = type.GetMethods(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
            for (int i = 0; i < methods.Length; i++)
            {
                CommandAttributeVerifier verifier = new CommandAttributeVerifier(methods[i]);
                if (!verifier.hasCommandAttribute)
                {
                    continue;
                }

                if (!verifier.isDeclarationSupported)
                {
                    notificationsHandler.NotifyException(new UnsupportedCommandDeclaration(methods[i]));
                }
                else
                {
                    commands.Add(verifier.ExtractCommand());
                }
            }
            return(commands.ToArray());
        }