Beispiel #1
0
 public static IEnumerable EnumerateFields(this INoggolloquyObjectGetter obj)
 {
     for (ushort i = 0; i < obj.FieldCount; i++)
     {
         yield return(obj.GetNthObject(i));
     }
 }
Beispiel #2
0
        private static string PrintPrettyInternal(this INoggolloquyObjectGetter nogg, DepthPrinter depthPrinter)
        {
            depthPrinter.AddLine("[");
            using (depthPrinter.IncrementDepth())
            {
                for (ushort i = 0; i < nogg.FieldCount; i++)
                {
                    var obj = nogg.GetNthObject(i);
                    if (nogg.GetNthIsEnumerable(i))
                    {
                        if (obj is IEnumerable listObj)
                        {
                            bool hasItems = listObj.Any();
                            depthPrinter.AddLine(nogg.GetNthName(i) + " => " + (hasItems ? string.Empty : "[ ]"));
                            if (hasItems)
                            {
                                depthPrinter.AddLine("[");
                                using (depthPrinter.IncrementDepth())
                                {
                                    foreach (var listItem in listObj)
                                    {
                                        if (nogg.GetNthIsNoggolloquy(i))
                                        {
                                            if (listItem is INoggolloquyObjectGetter subNogg)
                                            {
                                                depthPrinter.AddLine(PrintNoggName(nogg, i));
                                                PrintPrettyInternal(subNogg, depthPrinter);
                                            }
                                            continue;
                                        }

                                        depthPrinter.AddLine(obj.ToStringSafe() + ",");
                                    }
                                }
                                depthPrinter.AddLine("]");
                            }
                        }
                        continue;
                    }

                    if (nogg.GetNthIsNoggolloquy(i))
                    {
                        if (obj is INoggolloquyObjectGetter subNogg)
                        {
                            depthPrinter.AddLine(PrintNoggName(nogg, i));
                            PrintPrettyInternal(subNogg, depthPrinter);
                        }
                        continue;
                    }

                    depthPrinter.AddLine(nogg.GetNthName(i) + ": " + obj.ToStringSafe());
                }
            }
            depthPrinter.AddLine("]");
            return(depthPrinter.ToString());
        }