private void BuildItem(IHostService host, ItemViewModel item, FileModel model)
 {
     item.Summary = Markup(host, item.Summary, model);
     item.Remarks = Markup(host, item.Remarks, model);
     item.Conceptual = Markup(host, item.Conceptual, model);
     if (item.Syntax?.Return?.Description != null)
     {
         item.Syntax.Return.Description = Markup(host, item.Syntax?.Return?.Description, model);
     }
     var parameters = item.Syntax?.Parameters;
     if (parameters != null)
     {
         foreach (var parameter in parameters)
         {
             parameter.Description = Markup(host, parameter.Description, model);
         }
     }
     if (item.Exceptions != null)
     {
         foreach (var exception in item.Exceptions)
         {
             exception.Description = Markup(host, exception.Description, model);
         }
     }
 }
 private static XRefSpec GetXRefInfo(ItemViewModel item, string href)
 {
     var result = new XRefSpec
     {
         Uid = item.Uid,
         Name = item.Name,
         Href = ((RelativePath)href).GetPathFromWorkingFolder(),
     };
     if (!string.IsNullOrEmpty(item.NameForCSharp))
     {
         result["name.csharp"] = item.NameForCSharp;
     }
     if (!string.IsNullOrEmpty(item.NameForVB))
     {
         result["name.vb"] = item.NameForVB;
     }
     if (!string.IsNullOrEmpty(item.FullName))
     {
         result["fullName"] = item.FullName;
     }
     if (!string.IsNullOrEmpty(item.FullNameForCSharp))
     {
         result["fullName.csharp"] = item.FullNameForCSharp;
     }
     if (!string.IsNullOrEmpty(item.FullNameForVB))
     {
         result["fullName.vb"] = item.FullNameForVB;
     }
     return result;
 }
Пример #3
0
 private void PatchViewModel(ItemViewModel item, string comment)
 {
     var commentModel = TripleSlashCommentModel.CreateModel(comment, TripleSlashCommentParserContext.Instance);
     var summary = commentModel.Summary;
     if (!string.IsNullOrEmpty(summary))
     {
         item.Summary = summary;
     }
     var remarks = commentModel.Remarks;
     if (!string.IsNullOrEmpty(remarks))
     {
         item.Remarks = remarks;
     }
     var exceptions = commentModel.Exceptions;
     if (exceptions != null && exceptions.Count > 0)
     {
         item.Exceptions = exceptions;
     }
     var sees = commentModel.Sees;
     if (sees != null && sees.Count > 0)
     {
         item.Sees = sees;
     }
     var seeAlsos = commentModel.SeeAlsos;
     if (seeAlsos != null && seeAlsos.Count > 0)
     {
         item.SeeAlsos = seeAlsos;
     }
     var examples = commentModel.Examples;
     if (examples != null && examples.Count > 0)
     {
         item.Examples = examples;
     }
     if (item.Syntax != null)
     {
         if (item.Syntax.Parameters != null)
         {
             foreach (var p in item.Syntax.Parameters)
             {
                 var description = commentModel.GetParameter(p.Name);
                 if (!string.IsNullOrEmpty(description))
                 {
                     p.Description = description;
                 }
             }
         }
         if (item.Syntax.Return != null)
         {
             var returns = commentModel.Returns;
             if (!string.IsNullOrEmpty(returns))
             {
                 item.Syntax.Return.Description = returns;
             }
         }
     }
     // todo more.
 }
Пример #4
0
        public static ItemViewModel FromModel(MetadataItem model)
        {
            if (model == null)
            {
                return null;
            }
            var result = new ItemViewModel
            {
                Uid = model.Name,
                Parent = model.Parent?.Name,
                Children = model.Items?.Select(x => x.Name).OrderBy(s => s).ToList(),
                Href = model.Href,
                Type = model.Type,
                Source = model.Source,
                Documentation = model.Documentation,
                AssemblyNameList = model.AssemblyNameList,
                NamespaceName = model.NamespaceName,
                Summary = model.Summary,
                Remarks = model.Remarks,
                Examples = model.Examples,
                Syntax = SyntaxDetailViewModel.FromModel(model.Syntax),
                Overridden = model.Overridden,
                Exceptions = model.Exceptions,
                Sees = model.Sees,
                SeeAlsos = model.SeeAlsos,
                Inheritance = model.Inheritance,
                Implements = model.Implements,
                InheritedMembers = model.InheritedMembers,
            };

            result.Id = model.Name.Substring((model.Parent?.Name?.Length ?? -1) + 1);

            result.Name = model.DisplayNames.GetLanguageProperty(SyntaxLanguage.Default);
            var nameForCSharp = model.DisplayNames.GetLanguageProperty(SyntaxLanguage.CSharp);
            if (result.Name != nameForCSharp)
            {
                result.NameForCSharp = nameForCSharp;
            }
            var nameForVB = model.DisplayNames.GetLanguageProperty(SyntaxLanguage.VB);
            if (result.Name != nameForVB)
            {
                result.NameForVB = nameForVB;
            }

            result.FullName = model.DisplayQualifiedNames.GetLanguageProperty(SyntaxLanguage.Default);
            var fullnameForCSharp = model.DisplayQualifiedNames.GetLanguageProperty(SyntaxLanguage.CSharp);
            if (result.FullName != fullnameForCSharp)
            {
                result.FullNameForCSharp = fullnameForCSharp;
            }
            var fullnameForVB = model.DisplayQualifiedNames.GetLanguageProperty(SyntaxLanguage.VB);
            if (result.FullName != fullnameForVB)
            {
                result.FullNameForVB = fullnameForVB;
            }

            return result;
        }
 private static MergeItem CreateMergeItemCore(ItemViewModel majorItem, PageViewModel page)
 {
     return new MergeItem
     {
         MajorItem = majorItem,
         Children = new SortedSet<string>(majorItem.Children ?? Enumerable.Empty<string>()),
         Platform = new SortedSet<string>(majorItem.Platform ?? Enumerable.Empty<string>()),
         MinorItems = page?.Items.Where(x => x.Uid != majorItem.Uid).ToDictionary(item => item.Uid, item => CreateMergeItemCore(item, null)),
         References = page?.References.ToDictionary(item => item.Uid),
         Metadata = page?.Metadata,
     };
 }
Пример #6
0
        public static ItemViewModel FromModel(MetadataItem model)
        {
            if (model == null)
            {
                return(null);
            }
            var result = new ItemViewModel
            {
                Uid              = model.Name,
                Parent           = model.Parent?.Name,
                Children         = model.Items?.Select(x => x.Name).OrderBy(s => s).ToList(),
                Type             = model.Type,
                Source           = model.Source,
                Documentation    = model.Documentation,
                AssemblyNameList = model.AssemblyNameList,
                NamespaceName    = model.NamespaceName,
                Summary          = model.Summary,
                Remarks          = model.Remarks,
                Examples         = model.Examples,
                Syntax           = SyntaxDetailViewModel.FromModel(model.Syntax),
                Overridden       = model.Overridden,
                Exceptions       = model.Exceptions,
                Sees             = model.Sees,
                SeeAlsos         = model.SeeAlsos,
                Inheritance      = model.Inheritance,
                Implements       = model.Implements,
                InheritedMembers = model.InheritedMembers,
            };

            result.Id = model.Name.Substring((model.Parent?.Name?.Length ?? -1) + 1);

            result.Name = model.DisplayNames.GetLanguageProperty(SyntaxLanguage.Default);
            var nameForCSharp = model.DisplayNames.GetLanguageProperty(SyntaxLanguage.CSharp);

            if (result.Name != nameForCSharp)
            {
                result.NameForCSharp = nameForCSharp;
            }
            var nameForVB = model.DisplayNames.GetLanguageProperty(SyntaxLanguage.VB);

            if (result.Name != nameForVB)
            {
                result.NameForVB = nameForVB;
            }

            result.FullName = model.DisplayQualifiedNames.GetLanguageProperty(SyntaxLanguage.Default);
            var fullnameForCSharp = model.DisplayQualifiedNames.GetLanguageProperty(SyntaxLanguage.CSharp);

            if (result.FullName != fullnameForCSharp)
            {
                result.FullNameForCSharp = fullnameForCSharp;
            }
            var fullnameForVB = model.DisplayQualifiedNames.GetLanguageProperty(SyntaxLanguage.VB);

            if (result.FullName != fullnameForVB)
            {
                result.FullNameForVB = fullnameForVB;
            }

            var modifierCSharp = model.Modifiers.GetLanguageProperty(SyntaxLanguage.CSharp);

            if (modifierCSharp?.Count > 0)
            {
                result.Modifiers["csharp"] = modifierCSharp;
            }
            var modifierForVB = model.Modifiers.GetLanguageProperty(SyntaxLanguage.VB);

            if (modifierForVB?.Count > 0)
            {
                result.Modifiers["vb"] = modifierForVB;
            }

            return(result);
        }