示例#1
0
        private static WordsTree CountWords(string rootDir)
        {
            Console.WriteLine("------------------------------------");
            Console.WriteLine("Counting words.");
            var tree = new WordsTree()
            {
                Name = rootDir
            };

            var fileCount = 0;

            GetRelevantFiles(rootDir)
            .AsParallel()
            .ForAll(file =>
            {
                var shorname   = file.Substring(rootDir.Length);
                WordDo[] words =
                    new CSharpExtractor(file)
                    .CountOccurences()
                    .Select(w => w.ToDo())
                    .ToArray();
                tree.Add(shorname, words);

                fileCount++;
                if (fileCount % 100 == 0)
                {
                    Console.WriteLine($"Processing {shorname}, #{fileCount}");
                }
            });
            return(tree);
        }
示例#2
0
 private static WordsTree GetTree()
 {
     return(s_Cache ?? (s_Cache = Load()));
 }