public static string Serialize(object obj, TextSerializerType type) { if (type == TextSerializerType.Yaml) { return(yamlSerializer.Serialize(obj)); } else if (type == TextSerializerType.Json) { return(JsonConvert.SerializeObject(obj, Formatting.Indented)); } else if (type == TextSerializerType.Xml) { return(XmlSerializerUtility.GetString(obj, true)); } throw new NotImplementedException(); }
public static void AppendLine(this StringBuilder sb, object value, TextSerializerType type) { var text = TextSerializer.Serialize(value, type); sb.AppendLine(text); }