public static ApiLinkInfoBuildOutput FromModel(LinkInfo model, Dictionary <string, ApiReferenceBuildOutput> references, string[] supportedLanguages) { if (model == null) { return(null); } if (model.LinkType == LinkType.CRef) { return(new ApiLinkInfoBuildOutput { LinkType = LinkType.CRef, Type = ApiBuildOutputUtility.GetApiNames(model.LinkId, references, supportedLanguages), _needExpand = false, }); } else { return(new ApiLinkInfoBuildOutput { LinkType = LinkType.HRef, Url = ApiBuildOutputUtility.GetHref(model.LinkId, model.AltText), }); } }
public static ApiReferenceBuildOutput FromModel(ReferenceViewModel vm, string[] supportedLanguages) { if (vm == null) { return(null); } // TODO: may lead to potential problems with have vm.Additional["syntax"] as SyntaxDetailViewModel // It is now working as syntax is set only in FillReferenceInformation and not from YAML deserialization var result = new ApiReferenceBuildOutput { Uid = vm.Uid, Id = Utility.GetHtmlId(vm.Uid), Parent = vm.Parent, Definition = vm.Definition, IsExternal = vm.IsExternal, Href = vm.Href, Name = ApiBuildOutputUtility.TransformToLanguagePairList(vm.Name, vm.NameInDevLangs, supportedLanguages), NameWithType = ApiBuildOutputUtility.TransformToLanguagePairList(vm.NameWithType, vm.NameWithTypeInDevLangs, supportedLanguages), FullName = ApiBuildOutputUtility.TransformToLanguagePairList(vm.FullName, vm.FullNameInDevLangs, supportedLanguages), Spec = GetSpecNames(ApiBuildOutputUtility.GetXref(vm.Uid, vm.FullName, vm.Name), supportedLanguages, vm.Specs), Metadata = vm.Additional, }; object syntax; if (result.Metadata.TryGetValue("syntax", out syntax)) { result.Syntax = ApiSyntaxBuildOutput.FromModel(syntax as SyntaxDetailViewModel, supportedLanguages); result.Metadata.Remove("syntax"); } return(result); }
public void Expand(Dictionary <string, ApiReferenceBuildOutput> references, string[] supportedLanguages) { if (!_isExpanded) { Type = ApiBuildOutputUtility.GetReferenceViewModel(Type?.Uid, references, supportedLanguages); _isExpanded = true; } }
public void Expand(Dictionary <string, ApiReferenceBuildOutput> references, string[] supportedLanguages) { if (_needExpand) { _needExpand = false; Type = ApiBuildOutputUtility.GetApiNames(Type?.Uid, references, supportedLanguages); } }
private static string GetCompositeName(SpecViewModel svm) { // If href does not exists, return full name if (string.IsNullOrEmpty(svm.Uid)) { return(System.Web.HttpUtility.HtmlEncode(svm.FullName)); } // If href exists, return name with href return(ApiBuildOutputUtility.GetXref(svm.Uid, svm.FullName, svm.Name)); }
public void Expand(Dictionary <string, ApiReferenceBuildOutput> references, string[] supportedLanguages) { if (!_isExpanded) { Inheritance = Inheritance?.Select(i => ApiBuildOutputUtility.GetReferenceViewModel(i.Uid, references, supportedLanguages)).ToList(); Syntax?.Expand(references, supportedLanguages); SeeAlsos?.ForEach(e => e.Expand(references, supportedLanguages)); Sees?.ForEach(e => e.Expand(references, supportedLanguages)); Exceptions?.ForEach(e => e.Expand(references, supportedLanguages)); _isExpanded = true; } }
public static ApiExceptionInfoBuildOutput FromModel(ExceptionInfo model, Dictionary <string, ApiReferenceBuildOutput> references, string[] supportedLanguages) { if (model == null) { return(null); } return(new ApiExceptionInfoBuildOutput { Type = ApiBuildOutputUtility.GetApiNames(model.Type, references, supportedLanguages), Description = model.Description, _needExpand = false, }); }
public static ApiCrefInfoBuildOutput FromModel(CrefInfo model, Dictionary <string, ApiReferenceBuildOutput> references, string[] supportedLanguages) { if (model == null) { return(null); } return(new ApiCrefInfoBuildOutput { Type = ApiBuildOutputUtility.GetReferenceViewModel(model.Type, references, supportedLanguages), Description = model.Description, _isExpanded = true, }); }
public static ApiParameterBuildOutput FromModel(ApiParameter model, Dictionary <string, ApiReferenceBuildOutput> references, string[] supportedLanguages) { if (model == null) { return(null); } return(new ApiParameterBuildOutput { Name = model.Name, Type = ApiBuildOutputUtility.GetReferenceViewModel(model.Type, references, supportedLanguages), Description = model.Description, }); }
private static List <ApiReferenceBuildOutput> GetReferenceList(List <string> uids, Dictionary <string, ApiReferenceBuildOutput> references, string[] supportedLanguages, bool extractIndex = false) { if (extractIndex) { return(uids?.Select((u, i) => ApiBuildOutputUtility.GetReferenceViewModel(u, references, supportedLanguages, i)).ToList()); } else { return(uids?.Select(u => ApiBuildOutputUtility.GetReferenceViewModel(u, references, supportedLanguages)).ToList()); } }
public void Expand(Dictionary <string, ApiReferenceBuildOutput> references, string[] supportedLanguages) { if (_needExpand) { _needExpand = false; Inheritance = Inheritance?.Select(i => ApiBuildOutputUtility.GetReferenceViewModel(i.Uid, references, supportedLanguages)).ToList(); Implements = Implements?.Select(i => ApiBuildOutputUtility.GetApiNames(i.Uid, references, supportedLanguages)).ToList(); Syntax?.Expand(references, supportedLanguages); Overridden = ApiBuildOutputUtility.GetApiNames(Overridden?.Uid, references, supportedLanguages); SeeAlsos?.ForEach(e => e.Expand(references, supportedLanguages)); Sees?.ForEach(e => e.Expand(references, supportedLanguages)); Exceptions?.ForEach(e => e.Expand(references, supportedLanguages)); } }
public static ApiSyntaxBuildOutput FromModel(SyntaxDetailViewModel model, string[] supportedLanguages) { if (model == null) { return(null); } return(new ApiSyntaxBuildOutput { Content = ApiBuildOutputUtility.TransformToLanguagePairList(model.Content, model.Contents, supportedLanguages), Parameters = model.Parameters?.Select(ApiParameterBuildOutput.FromModel).ToList(), TypeParameters = model.TypeParameters?.Select(ApiParameterBuildOutput.FromModel).ToList(), Return = ApiParameterBuildOutput.FromModel(model.Return), }); }
public static ApiSyntaxBuildOutput FromModel(SyntaxDetailViewModel model, Dictionary <string, ApiReferenceBuildOutput> references, string[] supportedLanguages) { if (model == null) { return(null); } return(new ApiSyntaxBuildOutput { Content = ApiBuildOutputUtility.TransformToLanguagePairList(model.Content, model.Contents, supportedLanguages), Parameters = model.Parameters?.Select(s => ApiParameterBuildOutput.FromModel(s, references, supportedLanguages)).ToList(), TypeParameters = model.TypeParameters?.Select(ApiParameterBuildOutput.FromModel).ToList(), Return = ApiParameterBuildOutput.FromModel(model.Return, references, supportedLanguages), _needExpand = false, }); }
public static ApiReferenceBuildOutput FromModel(ItemViewModel vm) { if (vm == null) { return(null); } var output = new ApiReferenceBuildOutput { Uid = vm.Uid, Id = Utility.GetHtmlId(vm.Uid), IsExplicitInterfaceImplementation = vm.IsExplicitInterfaceImplementation, IsExtensionMethod = vm.IsExtensionMethod, Parent = vm.Parent, IsExternal = false, Href = vm.Href, Name = ApiBuildOutputUtility.TransformToLanguagePairList(vm.Name, vm.Names, vm.SupportedLanguages), NameWithType = ApiBuildOutputUtility.TransformToLanguagePairList(vm.NameWithType, vm.NamesWithType, vm.SupportedLanguages), FullName = ApiBuildOutputUtility.TransformToLanguagePairList(vm.FullName, vm.FullNames, vm.SupportedLanguages), Spec = GetSpecNames(ApiBuildOutputUtility.GetXref(vm.Uid, vm.FullName, vm.Name), vm.SupportedLanguages), Source = vm.Source, Documentation = vm.Documentation, AssemblyNameList = vm.AssemblyNameList, NamespaceName = vm.NamespaceName, Remarks = vm.Remarks, Examples = vm.Examples, Overridden = ApiNames.FromUid(vm.Overridden), Overload = ApiNames.FromUid(vm.Overload), SeeAlsos = vm.SeeAlsos?.Select(s => ApiLinkInfoBuildOutput.FromModel(s)).ToList(), Sees = vm.Sees?.Select(s => ApiLinkInfoBuildOutput.FromModel(s)).ToList(), Inheritance = vm.Inheritance?.Select(i => FromUid(i)).ToList(), Implements = vm.Implements?.Select(i => ApiNames.FromUid(i)).ToList(), InheritedMembers = vm.InheritedMembers, ExtensionMethods = vm.ExtensionMethods, Modifiers = vm.Modifiers, Conceptual = vm.Conceptual, Metadata = vm.Metadata, Attributes = vm.Attributes, Syntax = ApiSyntaxBuildOutput.FromModel(vm.Syntax, vm.SupportedLanguages), Exceptions = vm.Exceptions?.Select(s => ApiExceptionInfoBuildOutput.FromModel(s)).ToList(), }; output.Metadata["type"] = vm.Type; output.Metadata["summary"] = vm.Summary; output.Metadata["platform"] = vm.Platform; return(output); }
private static ApiBuildOutput FromModel(ItemViewModel model, Dictionary <string, ApiReferenceBuildOutput> references, Dictionary <string, object> metadata) { if (model == null) { return(null); } var output = new ApiBuildOutput { Uid = model.Uid, Id = Utility.GetHtmlId(model.Uid), IsExplicitInterfaceImplementation = model.IsExplicitInterfaceImplementation, IsExtensionMethod = model.IsExtensionMethod, Parent = ApiBuildOutputUtility.GetReferenceViewModel(model.Parent, references, model.SupportedLanguages), Children = GetReferenceList(model.Children, references, model.SupportedLanguages), Href = model.Href, SupportedLanguages = model.SupportedLanguages, Name = ApiBuildOutputUtility.TransformToLanguagePairList(model.Name, model.Names, model.SupportedLanguages), NameWithType = ApiBuildOutputUtility.TransformToLanguagePairList(model.NameWithType, model.NamesWithType, model.SupportedLanguages), FullName = ApiBuildOutputUtility.TransformToLanguagePairList(model.FullName, model.FullNames, model.SupportedLanguages), Type = model.Type, Source = model.Source, Documentation = model.Documentation, AssemblyNameList = model.AssemblyNameList, NamespaceName = ApiBuildOutputUtility.GetReferenceViewModel(model.NamespaceName, references, model.SupportedLanguages), Summary = model.Summary, Remarks = model.Remarks, Examples = model.Examples, Syntax = ApiSyntaxBuildOutput.FromModel(model.Syntax, references, model.SupportedLanguages), Overridden = ApiBuildOutputUtility.GetApiNames(model.Overridden, references, model.SupportedLanguages), Overload = ApiBuildOutputUtility.GetApiNames(model.Overload, references, model.SupportedLanguages), Exceptions = GetCrefInfoList(model.Exceptions, references, model.SupportedLanguages), SeeAlsos = GetLinkInfoList(model.SeeAlsos, references, model.SupportedLanguages), Sees = GetLinkInfoList(model.Sees, references, model.SupportedLanguages), Inheritance = GetReferenceList(model.Inheritance, references, model.SupportedLanguages, true), Implements = model.Implements?.Select(u => ApiBuildOutputUtility.GetApiNames(u, references, model.SupportedLanguages)).ToList(), InheritedMembers = GetReferenceList(model.InheritedMembers, references, model.SupportedLanguages), ExtensionMethods = GetReferenceList(model.ExtensionMethods, references, model.SupportedLanguages), Conceptual = model.Conceptual, Platform = model.Platform, Attributes = model.Attributes, Metadata = metadata.Concat(model.Metadata.Where(p => !metadata.Keys.Contains(p.Key))).ToDictionary(p => p.Key, p => p.Value), }; output.DerivedClasses = GetReferenceList(model.DerivedClasses, references, model.SupportedLanguages, true, output.Level + 1); return(output); }
public static ApiCrefInfoBuildOutput FromModel(CrefInfo model, Dictionary <string, ApiReferenceBuildOutput> references, string[] supportedLanguages) { if (model == null) { return(null); } return(new ApiCrefInfoBuildOutput { Type = new ApiTypeAndSpec { Uid = model.Type, Spec = ApiBuildOutputUtility.GetSpec(model.Type, references, supportedLanguages), }, Description = model.Description, _needExpand = false, }); }
private static ApiBuildOutput FromModel(ItemViewModel model, Dictionary <string, ApiReferenceBuildOutput> references, Dictionary <string, object> metadata) { if (model == null) { return(null); } return(new ApiBuildOutput { Uid = model.Uid, Id = Utility.GetHtmlId(model.Uid), Parent = ApiBuildOutputUtility.GetReferenceViewModel(model.Parent, references, model.SupportedLanguages), Children = GetReferenceList(model.Children, references, model.SupportedLanguages), Href = model.Href, SupportedLanguages = model.SupportedLanguages, Name = ApiBuildOutputUtility.TransformToLanguagePairList(model.Name, model.Names, model.SupportedLanguages), FullName = ApiBuildOutputUtility.TransformToLanguagePairList(model.FullName, model.FullNames, model.SupportedLanguages), Type = model.Type, Source = model.Source, Documentation = model.Documentation, AssemblyNameList = model.AssemblyNameList, NamespaceName = ApiBuildOutputUtility.GetReferenceViewModel(model.NamespaceName, references, model.SupportedLanguages), Summary = model.Summary, Remarks = model.Remarks, Examples = model.Examples, Syntax = ApiSyntaxBuildOutput.FromModel(model.Syntax, references, model.SupportedLanguages), Overridden = ApiBuildOutputUtility.GetReferenceViewModel(model.Overridden, references, model.SupportedLanguages), Exceptions = GetCrefInfoList(model.Exceptions, references, model.SupportedLanguages), SeeAlsos = GetCrefInfoList(model.SeeAlsos, references, model.SupportedLanguages), Sees = GetCrefInfoList(model.Sees, references, model.SupportedLanguages), Inheritance = GetReferenceList(model.Inheritance, references, model.SupportedLanguages, true), Implements = GetReferenceList(model.Implements, references, model.SupportedLanguages), InheritedMembers = GetReferenceList(model.InheritedMembers, references, model.SupportedLanguages), Conceptual = model.Conceptual, Platform = model.Platform, Metadata = metadata.Concat(model.Metadata.Where(p => !metadata.Keys.Contains(p.Key))).ToDictionary(p => p.Key, p => p.Value), }); }
public static ApiLinkInfoBuildOutput FromModel(LinkInfo model) { if (model == null) { return(null); } if (model.LinkType == LinkType.CRef) { return(new ApiLinkInfoBuildOutput { LinkType = LinkType.CRef, Type = ApiNames.FromUid(model.LinkId), }); } else { return(new ApiLinkInfoBuildOutput { LinkType = LinkType.HRef, Url = ApiBuildOutputUtility.GetHref(model.LinkId, model.AltText), }); } }