Пример #1
0
        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),
                SeeAlsos         = vm.SeeAlsos?.Select(s => ApiCrefInfoBuildOutput.FromModel(s)).ToList(),
                Sees             = vm.Sees?.Select(s => ApiCrefInfoBuildOutput.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,
                Syntax           = ApiSyntaxBuildOutput.FromModel(vm.Syntax, vm.SupportedLanguages),
                Exceptions       = vm.Exceptions?.Select(s => ApiCrefInfoBuildOutput.FromModel(s)).ToList(),
            };

            output.Metadata["type"]     = vm.Type;
            output.Metadata["summary"]  = vm.Summary;
            output.Metadata["platform"] = vm.Platform;
            return(output);
        }
Пример #2
0
 private static List <ApiCrefInfoBuildOutput> GetCrefInfoList(List <CrefInfo> crefs,
                                                              Dictionary <string, ApiReferenceBuildOutput> references,
                                                              string[] supportedLanguages)
 {
     return(crefs?.Select(c => ApiCrefInfoBuildOutput.FromModel(c, references, supportedLanguages)).ToList());
 }