Exemplo n.º 1
0
        public string GetDocText()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(commandObject.IntanceType.Name);
            int cmdCount  = cmdAttrs.Length;
            int hostCount = commandHostAttrs.Length;

            for (int i = 0; i < hostCount; i++)
            {
                if (commandHosts[i].GetValue(commandObject.TargetInstance) is CommandObject cmdobj)
                {
                    CommandHostAttribute _hostAttr = commandHostAttrs[i];

                    foreach (var def in cmdobj.GenCommandOverview())
                    {
                        sb.Append($"{_hostAttr.GetDifinitionString()} {string.Join(" ", def)}");
                        yield return(Enumerable.Repeat(, 1).Concat(def));
                    }
                }
            }

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

                yield return(Enumerable.Repeat(_cmdAttr.GetDifinitionString(), 1).Concat(_paramInfos.Select(v => v.GetDifinitionString())));
            }
        }
        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[] { "    -" }
                        }
                    }