private static void SerializeObject(object obj, IndentedStringBuilder sb) { if (obj == null) { sb.Append("null"); return; } if (obj is string) { SerializeString(obj as string, sb); return; } if (obj is bool) { sb.Append(((bool)obj) ? "true" : "false"); return; } if (obj is short || obj is ushort || obj is int || obj is uint || obj is long || obj is ulong || obj is decimal || obj is float || obj is double) { sb.Append(obj); return; } if (obj is IEnumerable) { SerializeEnumerable(obj as IEnumerable, sb); return; } if (obj.GetType().GetTypeInfo().IsClass) { SerializeClass(obj, sb); return; } throw new ArgumentException(DesignCoreStrings.CouldNotSerialize(obj, obj.GetType().FullName)); }