Exemple #1
0
        public ReadSnippets ReadSnippets(string directory)
        {
            var snippetExtractor = FileSnippetExtractor.BuildShared();
            var packages         = ReadSnippets(directory, snippetExtractor).ToList();

            return(new ReadSnippets(packages));
        }
Exemple #2
0
 IEnumerable <Snippet> ReadSnippets(string directory, FileSnippetExtractor snippetExtractor)
 {
     return(fileFinder.FindFiles(directory)
            .SelectMany(file =>
     {
         using (var reader = File.OpenText(file))
         {
             return snippetExtractor.Read(reader, file).ToList();
         }
     }));
 }
Exemple #3
0
        IEnumerable <Snippet> ReadSnippets(string directory, FileSnippetExtractor snippetExtractor)
        {
            var files = new List <string>();

            FindFiles(directory, files);
            return(files
                   .SelectMany(file =>
            {
                using (var reader = File.OpenText(file))
                {
                    return snippetExtractor.AppendFromReader(reader, file).ToList();
                }
            }));
        }
Exemple #4
0
        List <Snippet> GetShared(string directory)
        {
            var sharedDirectory = Path.Combine(directory, "Shared");

            if (Directory.Exists(sharedDirectory))
            {
                var snippetExtractor = FileSnippetExtractor.BuildShared();
                return(ReadSnippets(sharedDirectory, snippetExtractor).ToList());
            }

            var allPath = Path.Combine(directory, Path.GetFileName(directory) + "_All");

            if (Directory.Exists(allPath))
            {
                var snippetExtractor = FileSnippetExtractor.BuildShared();
                return(ReadSnippets(allPath, snippetExtractor).ToList());
            }

            return(new List <Snippet>());
        }
Exemple #5
0
        VersionGroup ReadVersion(
            string versionDirectory,
            VersionRange version,
            string package,
            string packageAlias,
            bool isCurrent,
            IReadOnlyList <Snippet> componentShared,
            List <Snippet> globalShared)
        {
            var snippetExtractor = FileSnippetExtractor.Build(version, package, isCurrent);

            return(new VersionGroup(
                       version: version,
                       snippets: ReadSnippets(versionDirectory, snippetExtractor)
                       .Concat(componentShared)
                       .Concat(globalShared)
                       .ToList(),
                       directory: versionDirectory,
                       isCurrent: isCurrent,
                       package: package,
                       packageAlias: packageAlias));
        }