DevConsole.CommandBase[] LoadCommansInType(Type t) { List <CommandBase> temp = new List <DevConsole.CommandBase>(); MethodInfo[] methods = t.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo method in methods) { try { CommandAttributeVerifier cav = new CommandAttributeVerifier(method); if (cav.hasCommandAttribute) { CommandBase command = cav.ExtractCommand(commandTypes); if (command != null) { temp.Add(command); } } }catch (ConsoleException ce) { DevConsole.Console.LogError(ce); } } return(temp.ToArray()); }
private void CheckCommandTypeMatch(CommandTypeInfo[] commandTypes) { ParameterInfo[] parameters = this.method.GetParameters(); Type[] parameterType = new Type[(int)parameters.Length]; for (int i = 0; i < (int)parameters.Length; i++) { parameterType[i] = parameters[i].ParameterType; } for (int j = 0; j < (int)commandTypes.Length; j++) { if ((int)parameters.Length == commandTypes[j].parametersLength) { if (CommandAttributeVerifier.BothAreAction(this.method, commandTypes[j])) { if (!commandTypes[j].isGeneric) { this.commandType = commandTypes[j]; } else { this.commandType = commandTypes[j].MakeGeneric(parameterType); } break; } else if (CommandAttributeVerifier.BothAreFunc(this.method, commandTypes[j])) { if (!commandTypes[j].isGeneric) { this.commandType = commandTypes[j]; } else { this.commandType = commandTypes[j].MakeGeneric(parameterType.Concat <Type>((IEnumerable <Type>)(new Type[] { this.method.ReturnType })).ToArray <Type>()); } break; } } } }