Пример #1
0
        private SDArticle GetArticle(string line, Dictionary <string, string> tokens)
        {
            var       splitted = line.Split('#');
            SDArticle article  = null;

            if (splitted.Length > 1)
            {
                var articleFile = GetArticleFile(splitted[1]);
                if (articleFile != string.Empty && Path.GetExtension(articleFile) == ".csproj" || Path.GetExtension(articleFile) == ".sln")
                {
                    article = new SDDocPlaceholder
                    {
                        Title        = GetNavTitle(splitted[0]),
                        SolutionFile = articleFile
                    };
                }
                else if (articleFile != string.Empty && articleFile.StartsWith("http://") || articleFile.StartsWith("https://"))
                {
                    article = new SDArticleLink
                    {
                        Title = GetNavTitle(splitted[0]),
                        Link  = articleFile
                    };
                }
                else if (articleFile != string.Empty)
                {
                    var filename = Path.GetFileNameWithoutExtension(articleFile);
                    article = new SDArticle()
                    {
                        Id       = CreateArticleId(filename),
                        Title    = GetNavTitle(splitted[0]),
                        Filename = filename,
                        Content  = new SDTemplate(File.ReadAllText(articleFile), tokens)
                    };
                }
            }
            else
            {
                article = new SDArticlePlaceholder
                {
                    Title = GetNavTitle(splitted[0])
                };
            }

            return(article);
        }
Пример #2
0
        private SDArticle GetArticle(string line, Dictionary<string, string> tokens)
        {
            var splitted = line.Split('#');
            SDArticle article = null;

            if (splitted.Length > 1)
            {
                var articleFile = GetArticleFile(splitted[1]);
                if (articleFile != string.Empty && Path.GetExtension(articleFile) == ".csproj" || Path.GetExtension(articleFile) == ".sln")
                {
                    article = new SDDocPlaceholder
                    {
                        Title = GetNavTitle(splitted[0]),
                        SolutionFile = articleFile
                    };
                }
                else if(articleFile != string.Empty && articleFile.StartsWith("http://") || articleFile.StartsWith("https://"))
                {
                    article = new SDArticleLink
                    {
                        Title = GetNavTitle(splitted[0]),
                        Link = articleFile
                    };
                }
                else if(articleFile != string.Empty)
                {
                    var filename = Path.GetFileNameWithoutExtension(articleFile);
                    article = new SDArticle()
                    {
                        Id = CreateArticleId(filename),
                        Title = GetNavTitle(splitted[0]),
                        Filename = filename,
                        Content = new SDTemplate(File.ReadAllText(articleFile), tokens)
                    };
                }
            }
            else
            {
                article = new SDArticlePlaceholder
                {
                    Title = GetNavTitle(splitted[0])
                };
            }

            return article;
        }