public static TocItem Create(IMetadataDictionary data) { var tocItem = new TocItem() { Title = data.Get <string>("title"), Link = data.Get <string>("link"), }; if (data.ContainsKey("children")) { tocItem.Children = Create(data.GetList <IMetadataDictionary>("children")); } return(tocItem); }
public static List <TocItem> Create(IEnumerable <IMetadataDictionary> objects, TocItem parent = null) => objects?.Select(Create).ToList() ?? new List <TocItem>();