public static void TestOptGetter(OptGetter opt, params string[] p) { // GetOptResult r = default; Exconsole.WriteLine(">" + p.JoinBy(" ")); opt.BeginParse(p); bool eoa = false; while (!eoa) { GetOptError err; if ((err = opt.GetOpt(out var result)) == GetOptError.EndOfArguments) { eoa = true; } Exconsole.WriteLine($" {err}: {result.Type}: \"{Mix(result.Option, result.LongOption)}\", p: {result.Argument ?? "<null>"}, pp: {result.Arguments?.JoinBy(", ") ?? "<null>"}"); } opt.EndParse(); }
public static void PrintType(Type type) { if (type.IsVisible) { Exconsole.WriteColor("V", ConsoleColor.Green); } else if (type.IsNotPublic) { Exconsole.WriteColor("N", ConsoleColor.Red); } else { Exconsole.Write("-"); } if (type.IsNested) { Exconsole.WriteColor("N", ConsoleColor.Blue); } else { Exconsole.Write("-"); } if (type.IsGenericType) { Exconsole.WriteColor("G", ConsoleColor.Yellow); } else { Exconsole.Write("-"); } if (type.IsEnum) { Exconsole.WriteColor("E", ConsoleColor.DarkCyan); } else if (type.IsSubclassOf(typeof(Delegate))) { Exconsole.WriteColor("D", ConsoleColor.Yellow); } else if (type.IsInterface) { Exconsole.WriteColor("I", ConsoleColor.Red); } else if (type.IsAbstract && type.IsSealed) { Exconsole.WriteColor("S", ConsoleColor.Cyan); } else if (type.IsAbstract) { Exconsole.WriteColor("A", ConsoleColor.DarkRed); } else if (type.IsValueType) { Exconsole.WriteColor("V", ConsoleColor.DarkGreen); } else if (type.IsSealed) { Exconsole.WriteColor("X", ConsoleColor.Green); } else { Exconsole.Write("-"); } if (type.IsAnsiClass) { Exconsole.WriteColor("A", ConsoleColor.DarkRed); } else if (type.IsUnicodeClass) { Exconsole.WriteColor("U", ConsoleColor.DarkGreen); } else if (type.IsAutoClass) { Exconsole.WriteColor("T", ConsoleColor.Yellow); } else { Exconsole.Write("-"); } Exconsole.Write(" "); Exconsole.WriteLine(type); }