public static object Invoke(MethodInfo[] methods, CommandAttribute[] attributes, CommandArguAttribute[][] paramInfos, object instance, string methodName, IArgument[] args, StringComparison stringComparison)
        {
            bool matchNameMethodFound = false;

            for (int i = 0, end = methods.Length; i < end; i++)
            {
                MethodInfo       method  = methods[i];
                CommandAttribute cmdattr = attributes[i];
                if (cmdattr.IsCorrectName(methodName, stringComparison))
                {
                    matchNameMethodFound = true;
                    CommandArguAttribute[] _paramInfos = paramInfos[i];
                    CommandAttribute       attribute   = attributes[i];
                    if (attribute == null)
                    {
                        throw new ArgumentOutOfRangeException(nameof(method), "Specified method is not supported. Please add 'Command' Attribute first.");
                    }
                    if (TryFormatArguments(_paramInfos, args, stringComparison, out var formatedArgs))
                    {
                        if (TryConvertArguments(_paramInfos, attribute.ArgumentConverters, ref formatedArgs, stringComparison))
                        {
                            object[] methodParamObjs = GetArgumentObjects(formatedArgs);
                            return(method.Invoke(instance, methodParamObjs));
                        }
                    }
                }
            }

            if (matchNameMethodFound)
            {
                throw new CommandOverrideNotFoundException(methodName);
            }

            throw new CommandEntryPointNotFoundException(methodName);
        }
 public static bool CanInvoke(CommandAttribute cmdattrs, CommandArguAttribute[] paramInfos, string methodName, IArgument[] args, StringComparison stringComparison)
 {
     return
         (cmdattrs.IsCorrectName(methodName, stringComparison) &&
          TryFormatArguments(paramInfos, args, stringComparison, out var formatedArgs) &&
          TryConvertArguments(paramInfos, cmdattrs.ArgumentConverters, ref formatedArgs, stringComparison));
 }
 public static bool TryInvoke(MethodInfo[] methods, CommandAttribute[] attributes, CommandArguAttribute[][] paramInfos, object instance, string methodName, IArgument[] args, StringComparison stringComparison, out object result)
 {
     result = null;
     for (int i = 0, end = methods.Length; i < end; i++)
     {
         MethodInfo       method  = methods[i];
         CommandAttribute cmdattr = attributes[i];
         if (cmdattr.IsCorrectName(methodName, stringComparison))
         {
             if (TryInvoke(method, attributes[i], paramInfos[i], instance, args, stringComparison, out result))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
        public IEnumerable <IEnumerable <string> > GenCommandDetails(string cmdname, StringComparison stringComparison)
        {
            int cmdCount  = cmdAttrs.Length;
            int hostCount = commandHostAttrs.Length;

            for (int i = 0; i < hostCount; i++)
            {
                if (commandHosts[i].GetValue(instance) is CommandObject cmdobj)
                {
                    CommandHostAttribute _hostAttr = commandHostAttrs[i];
                    if (_hostAttr.IsCorrectName(cmdname, stringComparison))
                    {
                        foreach (var def in cmdobj.GenCommandOverview())
                        {
                            yield return(new string[] { _hostAttr.CommandName, ":" });

                            yield return(new string[] { "  ", _hostAttr.GetDifinitionString() }.Concat(def));
                        }
                        yield break;
                    }
                }
            }

            for (int i = 0; i < cmdCount; i++)
            {
                CommandAttribute       _cmdAttr    = cmdAttrs[i];
                CommandArguAttribute[] _paramInfos = paramAttrs[i];

                if (_cmdAttr.IsCorrectName(cmdname, stringComparison))
                {
                    yield return(new string[] { _cmdAttr.GetDifinitionString() }.Concat(_paramInfos.Select(v => v.GetDifinitionString())));

                    if (!string.IsNullOrWhiteSpace(_cmdAttr.Description))
                    {
                        yield return new string[] { "  -", _cmdAttr.Description }
                    }
                    ;
                    foreach (var _paramInfo in _paramInfos)
                    {
                        if (!string.IsNullOrWhiteSpace(_paramInfo.Description))
                        {
                            yield return new string[] { "    -" }
                        }
                    }