Ejemplo n.º 1
0
 public static ApiExceptionInfoBuildOutput FromModel(ExceptionInfo model)
 {
     if (model == null)
     {
         return(null);
     }
     return(new ApiExceptionInfoBuildOutput
     {
         Type = ApiNames.FromUid(model.Type),
         Description = model.Description,
     });
 }
Ejemplo n.º 2
0
 public static ApiParameterBuildOutput FromModel(ApiParameter model)
 {
     if (model == null)
     {
         return(null);
     }
     return(new ApiParameterBuildOutput
     {
         Name = model.Name,
         Type = ApiNames.FromUid(model.Type),
         Description = model.Description,
     });
 }
Ejemplo n.º 3
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),
                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);
        }
Ejemplo n.º 4
0
        public static ApiNames GetApiNames(string key, Dictionary <string, ApiReferenceBuildOutput> references, string[] supportedLanguages)
        {
            if (string.IsNullOrEmpty(key))
            {
                return(null);
            }
            var result = ApiNames.FromUid(key);

            if (references.TryGetValue(key, out ApiReferenceBuildOutput arbo))
            {
                result.Definition   = arbo.Definition;
                result.Name         = arbo.Name;
                result.NameWithType = arbo.NameWithType;
                result.FullName     = arbo.FullName;
                result.Spec         = arbo.Spec;
            }

            return(result);
        }
Ejemplo n.º 5
0
 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),
         });
     }
 }