• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Plugins.FileModel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.DocAsCode.Plugins.FileModel的典型用法代码示例。如果您正苦于以下问题:C# FileModel类的具体用法?C# FileModel怎么用?C# FileModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FileModel类属于Microsoft.DocAsCode.Plugins命名空间,在下文中一共展示了FileModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Build

 public override void Build(FileModel model, IHostService host)
 {
     switch (model.Type)
     {
         case DocumentType.Article:
             var restApi = (RestApiRootItemViewModel)model.Content;
             BuildItem(host, restApi, model);
             if (restApi.Children != null)
             {
                 foreach (var item in restApi.Children)
                 {
                     BuildItem(host, item, model);
                 }
             }
             if (restApi.Tags != null)
             {
                 foreach (var tag in restApi.Tags)
                 {
                     BuildTag(host, tag, model);
                 }
             }
             break;
         case DocumentType.Overwrite:
             BuildItem(host, model);
             break;
         default:
             throw new NotSupportedException();
     }
 }
开发者ID:vicancy,项目名称:docfx,代码行数:29,代码来源:BuildRestApiDocument.cs


示例2: Build

        public override void Build(FileModel model, IHostService host)
        {
            var toc = (TocItemViewModel)model.Content;
            BuildCore(toc, model, host);

            // todo : metadata.
        }
开发者ID:vicancy,项目名称:docfx,代码行数:7,代码来源:BuildTocDocument.cs


示例3: ValidateToc

        private void ValidateToc(TocItemViewModel item, FileModel model, IHostService hostService)
        {
            if (!PathUtility.IsRelativePath(item.Href)) return;
            var file = model.File;
            var originalFile = model.OriginalFileAndType.File;
            // Special handle for folder ends with '/'
            FileAndType originalTocFile = null;

            string fileName = Path.GetFileName(item.Href);
            if (string.IsNullOrEmpty(fileName))
            {
                var href = item.Href + "toc.yml";
                var absHref = (RelativePath)file + (RelativePath)href;
                string tocPath = absHref.GetPathFromWorkingFolder();
                if (!hostService.SourceFiles.TryGetValue(tocPath, out originalTocFile))
                {
                    href = item.Href + "toc.md";
                    absHref = (RelativePath)file + (RelativePath)href;
                    tocPath = absHref.GetPathFromWorkingFolder();
                    if (!hostService.SourceFiles.TryGetValue(tocPath, out originalTocFile))
                    {
                        var error = $"Unable to find either toc.yml or toc.md inside {item.Href}. Make sure the file is included in config file docfx.json!";
                        Logger.LogError(error, file: model.LocalPathFromRepoRoot);
                        throw new DocumentException(error);
                    }
                }

                Logger.LogInfo($"TOC file {href} inside {item.Href} is used", file: model.LocalPathFromRepoRoot);
                item.Href = href;
                item.OriginalHref = item.Href;
            }

            // Set default homepage
            SetDefaultHomepage(item, originalTocFile, model);
        }
开发者ID:ansyral,项目名称:docfx,代码行数:35,代码来源:BuildTocDocument.cs


示例4: GetTagsFromOverwriteDocument

 public IEnumerable<RestApiTagViewModel> GetTagsFromOverwriteDocument(FileModel overwriteModel, string uid, IHostService host)
 {
     return OverwriteDocumentReader.Transform<RestApiTagViewModel>(
         overwriteModel,
         uid,
         s => BuildRestApiDocument.BuildTag(host, s, overwriteModel, content => content != null && content.Trim() == Constants.ContentPlaceholder));
 }
开发者ID:vicancy,项目名称:docfx,代码行数:7,代码来源:ApplyOverwriteDocumentForRestApi.cs


示例5: BuildCore

        private void BuildCore(TocItemViewModel item, FileModel model, IHostService hostService)
        {
            if (item == null)
            {
                return;
            }

            var linkToUids = new HashSet<string>();
            var linkToFiles = new HashSet<string>();
            if (Utility.IsSupportedRelativeHref(item.Href))
            {
                linkToFiles.Add(ParseFile(item.Href));
            }

            if (Utility.IsSupportedRelativeHref(item.Homepage))
            {
                linkToFiles.Add(ParseFile(item.Homepage));
            }

            if (!string.IsNullOrEmpty(item.TopicUid))
            {
                linkToUids.Add(item.TopicUid);
            }

            model.LinkToUids = model.LinkToUids.Union(linkToUids);
            model.LinkToFiles = model.LinkToFiles.Union(linkToFiles);

            if (item.Items != null)
            {
                foreach (var i in item.Items)
                {
                    BuildCore(i, model, hostService);
                }
            }
        }
开发者ID:vicancy,项目名称:docfx,代码行数:35,代码来源:BuildTocDocument.cs


示例6: GetItemsFromOverwriteDocument

 public IEnumerable<ItemViewModel> GetItemsFromOverwriteDocument(FileModel fileModel, string uid, IHostService host)
 {
     return OverwriteDocumentReader.Transform<ItemViewModel>(
         fileModel,
         uid,
         s => BuildManagedReferenceDocument.BuildItem(host, s, fileModel, content => content != null && content.Trim() == Constants.ContentPlaceholder));
 }
开发者ID:dotnet,项目名称:docfx,代码行数:7,代码来源:ApplyOverwriteDocumentForMREF.cs


示例7: Save

        public SaveResult Save(FileModel model)
        {
            if (model.Type != DocumentType.Article)
            {
                throw new NotSupportedException();
            }

            string path = Path.Combine(model.BaseDir, model.File);
            try
            {
                JsonUtility.Serialize(path, model.Content);
            }
            catch (PathTooLongException e)
            {
                Logger.LogError($"Path \"{path}\": {e.Message}");
                throw;
            }

            return new SaveResult
            {
                DocumentType = model.DocumentType ?? "Conceptual",
                ModelFile = model.File,
                LinkToFiles = model.Properties.LinkToFiles,
                LinkToUids = model.Properties.LinkToUids,
            };
        }
开发者ID:yonglehou,项目名称:docfx,代码行数:26,代码来源:ConceptualDocumentProcessor.cs


示例8: Save

        public override SaveResult Save(FileModel model)
        {
            if (model.FileAndType != model.OriginalFileAndType)
            {
                var targetFile = Path.Combine(model.BaseDir, model.File);
                Directory.CreateDirectory(Path.GetDirectoryName(targetFile));
                File.Copy(
                    Path.Combine(model.OriginalFileAndType.BaseDir, model.OriginalFileAndType.File),
                    targetFile,
                    true);
                File.SetAttributes(targetFile, FileAttributes.Normal);
            }
            var result = new SaveResult
            {
                DocumentType = "Resource",
                ResourceFile = model.File,
            };

            if (model.Content != null)
            {
                // For resources, e.g. image.png, file extension is kept
                result.FileWithoutExtension = model.File;
            }

            return result;
        }
开发者ID:vicancy,项目名称:docfx,代码行数:26,代码来源:ResourceDocumentProcessor.cs


示例9: BuildItem

 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);
         }
     }
 }
开发者ID:yodamaster,项目名称:docfx,代码行数:25,代码来源:BuildManagedReferenceDocument.cs


示例10: Save

 public override SaveResult Save(FileModel model)
 {
     return new SaveResult
     {
         DocumentType = "Toc",
         ModelFile = model.File,
     };
 }
开发者ID:ansyral,项目名称:docfx,代码行数:8,代码来源:TocDocumentProcessor.cs


示例11: Build

 public override void Build(FileModel model, IHostService host)
 {
     if (model.Type != DocumentType.Article && model.Type != DocumentType.Resource)
     {
         throw new NotSupportedException();
     }
     // todo : metadata.
 }
开发者ID:yodamaster,项目名称:docfx,代码行数:8,代码来源:BuildResourceDocument.cs


示例12: Save

 public SaveResult Save(FileModel model)
 {
     return new SaveResult
     {
         DocumentType = "Conceptual",
         ModelFile = model.File,
         LinkToFiles = linkToFiles.ToImmutableArray(),
     };
 }
开发者ID:dotnet,项目名称:docfx,代码行数:9,代码来源:RtfDocumentProcessor.cs


示例13: UpdateRelativePathAndAddTocMap

        private void UpdateRelativePathAndAddTocMap(TocViewModel toc, FileModel model, HashSet<string> links, Dictionary<string, HashSet<string>> tocMap, IHostService hostService)
        {
            if (toc == null) return;
            var file = model.File;
            var originalFile = model.OriginalFileAndType.File;
            foreach (var item in toc)
            {
                if (PathUtility.IsRelativePath(item.Href))
                {
                    // Special handle for folder ends with '/'
                    FileAndType originalTocFile = null;

                    string fileName = Path.GetFileName(item.Href);
                    if (string.IsNullOrEmpty(fileName))
                    {
                        var href = item.Href + "toc.yml";
                        var absHref = (RelativePath)file + (RelativePath)href;
                        string tocPath = absHref.GetPathFromWorkingFolder();
                        if (!hostService.SourceFiles.TryGetValue(tocPath, out originalTocFile))
                        {
                            href = item.Href + "toc.md";
                            absHref = (RelativePath)file + (RelativePath)href;
                            tocPath = absHref.GetPathFromWorkingFolder();
                            if (!hostService.SourceFiles.TryGetValue(tocPath, out originalTocFile))
                            {
                                var error = $"Unable to find either toc.yml or toc.md inside {item.Href}. Make sure the file is included in config file docfx.json!";
                                Logger.LogError(error, file: model.LocalPathFromRepoRoot);
                                throw new DocumentException(error);
                            }
                        }

                        Logger.LogInfo($"TOC file {href} inside {item.Href} is used", file: model.LocalPathFromRepoRoot);
                        item.Href = href;
                        item.OriginalHref = item.Href;
                    }

                    // Add toc.yml to tocMap before change item.Href to home page
                    item.Href = ((RelativePath)file + (RelativePath)item.Href).GetPathFromWorkingFolder();
                    if (item.OriginalHref != null) item.OriginalHref = ((RelativePath)file + (RelativePath)item.OriginalHref).GetPathFromWorkingFolder();

                    HashSet<string> value;
                    if (tocMap.TryGetValue(item.Href, out value))
                    {
                        value.Add(originalFile);
                    }
                    else
                    {
                        tocMap[item.Href] = new HashSet<string>(FilePathComparer.OSPlatformSensitiveComparer) { originalFile };
                    }
                    links.Add(item.Href);

                    SetHomepage(item, originalTocFile, model);
                }

                UpdateRelativePathAndAddTocMap(item.Items, model, links, tocMap, hostService);
            }
        }
开发者ID:yodamaster,项目名称:docfx,代码行数:57,代码来源:BuildTocDocument.cs


示例14: Save

 public override SaveResult Save(FileModel model)
 {
     return new SaveResult
     {
         DocumentType = "Toc",
         ModelFile = model.File,
         TocMap = model.Properties.TocMap,
         LinkToFiles = model.Properties.LinkToFiles
     };
 }
开发者ID:yodamaster,项目名称:docfx,代码行数:10,代码来源:TocDocumentProcessor.cs


示例15: Save

 public override SaveResult Save(FileModel model)
 {
     return new SaveResult
     {
         DocumentType = "Toc",
         FileWithoutExtension = Path.ChangeExtension(model.File, null),
         LinkToFiles = model.LinkToFiles.ToImmutableArray(),
         LinkToUids = model.LinkToUids,
     };
 }
开发者ID:dotnet,项目名称:docfx,代码行数:10,代码来源:TocDocumentProcessor.cs


示例16: Build

 public void Build(FileModel model, IHostService host)
 {
     model.File = Path.ChangeExtension(model.File, ".json");
     var toc = (TocViewModel)model.Content;
     HashSet<string> links = new HashSet<string>();
     Dictionary<string, HashSet<string>> tocMap = new Dictionary<string, HashSet<string>>();
     UpdateRelativePathAndAddTocMap(toc, model, links, tocMap, host);
     model.Properties.LinkToFiles = links.ToImmutableArray();
     model.Properties.TocMap = tocMap.ToImmutableDictionary();
     // todo : metadata.
 }
开发者ID:yonglehou,项目名称:docfx,代码行数:11,代码来源:TocDocumentProcessor.cs


示例17: Save

        public SaveResult Save(FileModel model)
        {
            HashSet<string> linkToFiles = CollectLinksAndFixDocument(model);

            return new SaveResult
            {
                DocumentType = "Conceptual",
                ModelFile = model.File,
                LinkToFiles = linkToFiles.ToImmutableArray(),
            };
        }
开发者ID:dotnet,项目名称:docfx,代码行数:11,代码来源:RtfDocumentProcessor.cs


示例18: CreateMergeItem

 private static MergeItem CreateMergeItem(string majorUid, FileModel model, IHostService host)
 {
     var vm = (PageViewModel)model.Content;
     var majorItem = vm.Items.Find(item => item.Uid == majorUid);
     if (majorItem == null)
     {
         host.LogError("Cannot find uid in model.", file: model.File);
         return null;
     }
     return CreateMergeItemCore(majorItem, vm);
 }
开发者ID:yodamaster,项目名称:docfx,代码行数:11,代码来源:MergeManagedReferenceDocument.cs


示例19: Markup

 private string Markup(IHostService host, string markdown, FileModel model)
 {
     if (string.IsNullOrEmpty(markdown))
     {
         return markdown;
     }
     var mr = host.Markup(markdown, model.FileAndType);
     ((HashSet<string>)model.Properties.LinkToFiles).UnionWith(mr.LinkToFiles);
     ((HashSet<string>)model.Properties.LinkToUids).UnionWith(mr.LinkToUids);
     return mr.Html;
 }
开发者ID:yodamaster,项目名称:docfx,代码行数:11,代码来源:BuildManagedReferenceDocument.cs


示例20: Build

        public override void Build(FileModel model, IHostService host)
        {
            if (model.Type != DocumentType.Article)
            {
                return;
            }
            var content = (Dictionary<string, object>)model.Content;
            var markdown = (string)content[ConceputalKey];
            var result = host.Markup(markdown, model.FileAndType);

            var htmlInfo = SeperateHtml(result.Html);
            content["title"] = htmlInfo.Title;
            content["rawTitle"] = htmlInfo.RawTitle;
            content[ConceputalKey] = htmlInfo.Content;

            if (result.YamlHeader != null && result.YamlHeader.Count > 0)
            {
                foreach (var item in result.YamlHeader)
                {
                    if (item.Key == "uid")
                    {
                        var uid = item.Value as string;
                        if (!string.IsNullOrWhiteSpace(uid))
                        {
                            model.Uids = new[] { uid }.ToImmutableArray();
                            content["uid"] = item.Value;
                        }
                    }
                    else
                    {
                        content[item.Key] = item.Value;
                        if (item.Key == DocumentTypeKey)
                        {
                            model.DocumentType = item.Value as string;
                        }
                    }
                }
            }
            model.Properties.LinkToFiles = result.LinkToFiles;
            model.Properties.LinkToUids = result.LinkToUids;
            model.Properties.XrefSpec = null;
            if (model.Uids.Length > 0)
            {
                model.Properties.XrefSpec = new XRefSpec
                {
                    Uid = model.Uids[0],
                    Name = TitleThumbnail(content["title"].ToString() ?? model.Uids[0], TitleThumbnailMaxLength),
                    Href = ((RelativePath)model.File).GetPathFromWorkingFolder()
                };
            }
            model.File = Path.ChangeExtension(model.File, ".json");
        }
开发者ID:yodamaster,项目名称:docfx,代码行数:52,代码来源:BuildConceptualDocument.cs



注:本文中的Microsoft.DocAsCode.Plugins.FileModel类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Framework.BuildTargetContext类代码示例发布时间:2022-05-26
下一篇:
C# WindowsInstaller.Session类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap