示例#1
0
 private int Depth(int cdepth)
 {
     if (!NextParts.Any())
     {
         return(cdepth);
     }
     return(cdepth + NextParts.Max(o => o.Depth(cdepth + 1)));
 }
示例#2
0
 public void Extend(FormattedString[] pre, CommandPart p)
 {
     if (pre.Length > 0 && NextParts.Any(o => o.ThisPart == pre[0]))
     {
         NextParts.First(o => o.ThisPart.Equals(pre[0])).Extend(pre.Skip(1).ToArray(), p);
     }
     else if (CType == CommandType.StaticList)
     {
         _staticList.Add(p);
     }
 }
示例#3
0
 public void Extend(params FormattedString[] p)
 {
     if (NextParts.Any(o => o.ThisPart == p[0]))
     {
         NextParts.First(o => o.ThisPart.Equals(p[0])).Extend(p.Skip(1).ToArray());
     }
     else if (CType == CommandType.StaticList)
     {
         _staticList.Add(FromArray(p));
     }
 }
示例#4
0
 public IEnumerable <CommandPart> PermuteCommands()
 {
     if (!NextParts.Any())
     {
         yield return(this);
     }
     else
     {
         foreach (var commandPart in NextParts.SelectMany(o => o.PermuteCommands()))
         {
             yield return(new CommandPart(ThisPart, commandPart));
         }
     }
 }
示例#5
0
 public IEnumerable <FormattedString> Permute()
 {
     if (!NextParts.Any())
     {
         yield return(ThisPart);
     }
     else
     {
         foreach (var commandPart in NextParts.SelectMany(o => o.Permute()))
         {
             yield return($"{ThisPart} {commandPart}");
         }
     }
 }
示例#6
0
 public IEnumerable <FormattedString> GetLevel(int level)
 {
     if (level == 0)
     {
         yield return(ThisPart);
     }
     else
     {
         foreach (var commandPart in NextParts.SelectMany(o => o.GetLevel(level - 1)))
         {
             yield return(commandPart);
         }
     }
 }
示例#7
0
        public FormattedString LevelString(bool showlevel = true, bool complete = true)
        {
            var b     = new FormattedString();
            var count = NextParts.Count();

            b.Append(ThisPart);
            if (count == 1)
            {
                b.Append(" ");
                b.Append(NextParts.First().LevelString(showlevel));
                return(b);
            }
            if (count != 0 && showlevel)
            {
                b.Append($"[ {FormattedString.Join("| ", NextParts.Select(o => o.LevelString(complete)))}] ");
            }
            else if (count != 0)
            {
                b.Append("...");
            }
            return(b);
        }
示例#8
0
 public IEnumerable <FormattedString> LevelOpts() => NextParts.Select(commandPart => commandPart.LevelString(false));