예제 #1
0
        private IEnumerable <RemoteDocumentationDocument> CopyDocuments(IEnumerable <IDocumentationDocument> sourceDocumentationDocuments, string documentationRootPath)
        {
            List <RemoteDocumentationDocument> finalDocumentationDocuments = new List <RemoteDocumentationDocument>();

            foreach (var item in sourceDocumentationDocuments)
            {
                var doc = new RemoteDocumentationDocument
                {
                    Path       = item.Path.Replace(documentationRootPath, "").Replace("\\", "/"),
                    LastUpdate = item.LastUpdate
                };

                if (doc.Path.StartsWith("/"))
                {
                    doc.Path = doc.Path.Substring(1, doc.Path.Length - 1);
                }

                if (item.SubDocumentsCount > 0)
                {
                    doc.SubDocuments = CopyDocuments(item.SubDocuments, documentationRootPath).ToArray();
                }

                finalDocumentationDocuments.Add(doc);
            }

            return(finalDocumentationDocuments);
        }
예제 #2
0
        private IDocumentationDocument CreateRemoteDocument <TDocumentationDocument>(RemoteDocumentationDocument remoteDocumentationDocument, IServiceProvider serviceProvider) where TDocumentationDocument : IDocumentationDocument, new()
        {
            if (remoteDocumentationDocument.SubDocumentsCount > 0)
            {
                var doc = new GenericDocumentationDocument
                {
                    Path         = remoteDocumentationDocument.Path,
                    LastUpdate   = remoteDocumentationDocument.LastUpdate,
                    DocumentType = DocumentationDocumentType.Folder
                };

                doc.SubDocuments = CopyDocuments <TDocumentationDocument>(remoteDocumentationDocument.SubDocuments, serviceProvider).ToArray();
                return(doc);
            }
            var docType = DocumentationHelper.GetDocumentationDocumentTypeFromName(remoteDocumentationDocument.Path);

            switch (docType)
            {
            case DocumentationDocumentType.Markdown:
                using (var scope = serviceProvider.CreateScope())
                {
                    return(new RemoteMarkdownDocument(serviceProvider)
                    {
                        Path = remoteDocumentationDocument.Path,
                        LastUpdate = remoteDocumentationDocument.LastUpdate
                    });
                }

            case DocumentationDocumentType.Pdf:
                return(new RemotePdfDocument
                {
                    Path = remoteDocumentationDocument.Path,
                    LastUpdate = remoteDocumentationDocument.LastUpdate
                });

            case DocumentationDocumentType.Html:
                return(new RemoteHtmlDocument(serviceProvider)
                {
                    Path = remoteDocumentationDocument.Path,
                    LastUpdate = remoteDocumentationDocument.LastUpdate
                });

            case DocumentationDocumentType.Word:
                return(new RemoteWordDocument(serviceProvider)
                {
                    Path = remoteDocumentationDocument.Path,
                    LastUpdate = remoteDocumentationDocument.LastUpdate
                });

            case DocumentationDocumentType.Drawio:
                return(new RemoteDrawioDocument
                {
                    Path = remoteDocumentationDocument.Path,
                    LastUpdate = remoteDocumentationDocument.LastUpdate
                });

            case DocumentationDocumentType.DrawioSvg:
                return(new RemoteDrawioSvgDocument
                {
                    Path = remoteDocumentationDocument.Path,
                    LastUpdate = remoteDocumentationDocument.LastUpdate
                });

            case DocumentationDocumentType.Folder:
            default:
                return(new GenericDocumentationDocument
                {
                    Path = remoteDocumentationDocument.Path,
                    LastUpdate = remoteDocumentationDocument.LastUpdate,
                    DocumentType = docType
                });
            }
        }