public Compile_files(Crawl_directory_tree crawlDirTree) { var split = new Split<Tuple<string, string>, string, string>( t => t.Item2, t => t.Item1 ); var validatePath = new Validate<string>( Directory.Exists, path => string.Format("Diretory to be indexed not found: {0}", path) ); this.in_Process = _ => split.Input(_); split.Output1 += validatePath.In_Validate; validatePath.Out_ValidData += crawlDirTree.In_Process; validatePath.Out_InvalidData += _ => this.Out_ValidationError(_); split.Output0 += _ => this.Out_IndexFilename(_); crawlDirTree.Out_FileFound += _ => this.Out_FileFound(_); }
public IndexFiles() { // Build var crawlDirTree = new Crawl_directory_tree(); var compileFiles = new Compile_files(crawlDirTree); var readLines = new Read_text_lines(); var splitLinesIntoWords = new Split_lines_into_words(); var readWords = new Read_words(readLines, splitLinesIntoWords); var filterWords = new Filter_words(); var extractWords = new Extract_words(readWords, filterWords); var compileWords = new Compile_words(); var writeIndexToFile = new Write_index_to_file(); var buildIndex = new Build_index(compileWords, writeIndexToFile); var logValidationError = new Log<string>(errMsg => "*** " + errMsg); var logException = new Log<Exception>(ex => "*** " + ex.Message + '\n' + ex.StackTrace); var handleEx = new HandleException<Tuple<string, string>>(); var asyncCompileFiles = new Asynchronize<Tuple<string, string>>(); var asyncBuildIndex = new Asynchronize<Tuple<string, string[]>>(); var countFilesFound = new CountItemsUntilNullForScatter<string>(); var parExtractWords = new Parallelize<string>(); var finishStreamOfFileWordsWithNull = new InsertNullAfterItemsForGather<Tuple<string, string[]>>(); // Bind this.in_Process = _ => asyncCompileFiles.In_Process(_); asyncCompileFiles.Out_ProcessSequentially += handleEx.In_Process; handleEx.Out_Process += compileFiles.In_Process; handleEx.Out_Exception += logException.In_Process; logException.Out_Data += _ => this.Out_UnhandledException(_); compileFiles.Out_FileFound += countFilesFound.In_Count; compileFiles.Out_FileFound += filename => { if (filename != null) this.Out_FileFoundToIndex(filename); }; countFilesFound.Out_Counted += parExtractWords.In_Process; parExtractWords.Out_ProcessInParallel += extractWords.In_Process; countFilesFound.Out_Count += finishStreamOfFileWordsWithNull.In_NumberOfItemsToGather; extractWords.Out_WordsExtracted += finishStreamOfFileWordsWithNull.In_Process; finishStreamOfFileWordsWithNull.Out_Gather += asyncBuildIndex.In_Process; asyncBuildIndex.Out_ProcessSequentially += buildIndex.In_Process; compileFiles.Out_IndexFilename += buildIndex.In_IndexFilename; compileFiles.Out_ValidationError += logValidationError.In_Process; logValidationError.Out_Data += _ => this.Out_ValidationError(_); buildIndex.Out_Statistics += _ => this.Out_Statistics(_); }