public int Eval(string args) { string relativePath; args = Util.NextToken(args, out relativePath); ReadableDargonNode nextNode; if (!DumperUtils.TryResolvePath(relativePath, out nextNode)) { DumperUtils.PrintUnableToResolvePath(relativePath); return(1); } else { Console.WriteLine("Listing directory " + DumperGlobals.CurrentNode.GetPath()); PrettyPrint.List( nextNode.Children.OrderBy(x => x.Name), new PrettyFormatter <ReadableDargonNode> { GetName = (n) => n.Name, GetBackground = (n) => n.Children.Any() ? ConsoleColor.DarkRed : ConsoleHelpers.DefaultBackgroundColor, GetForeground = (n) => n.Children.Any() ? ConsoleColor.White : ConsoleHelpers.DefaultForegroundColor, }); return(0); } }
public int Eval(string args) { string name; args = Tokenizer.Next(args, out name); if (ReplGlobals.Current == null) { ReplGlobals.Current = ReplGlobals.Root; } if (ReplGlobals.Root == null) { throw new Exception("Need to fetch mobs first"); } PrettyPrint.List( ReplGlobals.Current.Children, new PrettyFormatter <SomeNode> { GetBackground = n => { var color = ConsoleColor.Black; if (n.PropertyDto != null) { if (n.PropertyDto.HasGetter && n.PropertyDto.HasSetter) { color = ConsoleColor.DarkMagenta; } else if (n.PropertyDto.HasGetter) { color = ConsoleColor.DarkCyan; } else if (n.PropertyDto.HasSetter) { color = ConsoleColor.DarkRed; } } if (n.DataSetDto != null) { color |= (ConsoleColor)8; } return(color); } }); return(0); }