public Document(DocumentFormat df) { sb = new StringBuilder(); formatStrategy = df switch { DocumentFormat.Json => new Json(), DocumentFormat.Xml => new Xml(), _ => new Md() }; formatStrategy.Init(sb); }
public static string Convert(Dictionary <string, string> dic, IFormatStrategy format) { StringBuilder t = new(); format.Init(t); foreach (var item in dic) { format.AddElement(t, item.Key, item.Value); } format.Close(t); return(t.ToString()); }