当前位置: 首页>>代码示例>>C#>>正文


C# Plugins.FileModel类代码示例

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


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


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