private void InitTable(FileModel model, ImmutableList <string> metaNames) { var content = model.Content as PageViewModel; if (content?.Items != null) { var items = from item in content.Items select YamlUtility.ConvertTo <Dictionary <string, object> >(item); foreach (var item in items) { var property = GetTableItem(item, metaNames); if (property.Count > 0 && item.TryGetValue(Constants.PropertyName.Uid, out object uid)) { _propTable.Add((string)uid, property); } } } if (content?.Metadata != null && model.Uids.Length > 0) { var metadata = GetTableItem(content.Metadata, metaNames); if (metadata.Count > 0) { // share metadata for all uid in model foreach (var uid in model.Uids) { _metaTable.Add(uid.Name, metadata); } } } }
private IEnumerable <XRefSpec> GetXRefFromReference(PageViewModel vm) { if (vm.References == null) { yield break; } foreach (var reference in vm.References) { if (reference != null && reference.IsExternal != false) { var dict = YamlUtility.ConvertTo <Dictionary <string, object> >(reference); if (dict != null) { var spec = new XRefSpec(); foreach (var pair in dict) { var s = pair.Value as string; if (s != null) { spec[pair.Key] = s; } } yield return(spec); } } } }
private static XRefSpec GetExternalReference(ExternalReferencePackageCollection externalReferences, string uid) { if (!externalReferences.TryGetReference(uid, out ReferenceViewModel vm)) { return(null); } return(YamlUtility.ConvertTo <XRefSpec>(vm)); }
/// <summary> /// TODO: can save minimum info when ApiBuildOutput depends on global references instead of current page only /// </summary> /// <param name="item"></param> /// <returns></returns> private ReferenceViewModel ConvertToReference(ItemViewModel item) { // Use serializer to keep most info from item, e.g. reference's summary is possibly required by class template return(YamlUtility.ConvertTo <ReferenceViewModel>(item)); }
private static List <TocItemViewModel> GetRoots(IEnumerable <TreeItem> treeItems) { return(YamlUtility.ConvertTo <List <TocItemViewModel> >(treeItems)); }