public void SetTypoAnalyzerResult(TypoAnalyzerResult result) { this.keywordOccurrences = result.Keywords.OrderBy(t => t.Occurrences.Count()).ToArray(); this.occurrences = this.keywordOccurrences[0].Occurrences.Select(o => new OccurrenceItemViewModel(this.view) { Name = o }); }
public void OnAnalyzeButtonClickedWorker() { TypoAnalyzerResult result = this.analyzer.Analyze(this.PathToAnalyze, this.ExtensionToAnalyze, this); if (result != null) { this.view.ShowAnalyzeResult(result); } }
public void ShowAnalyzeResult(TypoAnalyzerResult result) { this.dispatcher.BeginInvoke(new Action(() => { SelectorWindow selectorWindow = new SelectorWindow(); selectorWindow.SetTypoAnalyzerResult(result); selectorWindow.Show(); this.Close(); })); }
private void AnalyzeFile(string file, TypoAnalyzerResult result) { string content = this.fileSystem.ReadFile(file); StringBuilder builder = new StringBuilder(); for (int i = 0; i < content.Length; i++) { char c = content[i]; if (char.IsLetter(c)) { if (char.IsUpper(c)) { if (builder.Length > 0) { string word = builder.ToString(); if (!this.correctWords.IsWordCorrect(word)) { result.AddOccurrence(word, file); } builder.Clear(); } c = char.ToLower(c); } builder.Append(c); } else { if (builder.Length > 0) { string word = builder.ToString(); if (!this.correctWords.IsWordCorrect(word)) { result.AddOccurrence(word, file); } builder.Clear(); } } } if (builder.Length > 0) { string word = builder.ToString(); if (!this.correctWords.IsWordCorrect(word)) { result.AddOccurrence(word, file); } builder.Clear(); } }
public TypoAnalyzerResult Analyze(string folder, string pattern, IProgressReporter progressReporter) { if (!this.fileSystem.Exists(folder)) { return(null); } var result = new TypoAnalyzerResult(); string[] files = this.fileSystem.EnumerateFiles(folder, pattern).ToArray(); progressReporter.Maximum = files.Length; foreach (var file in files) { progressReporter.Current++; this.AnalyzeFile(file, result); } return(result); }
internal void SetTypoAnalyzerResult(TypoAnalyzerResult result) { this.viewModel.SetTypoAnalyzerResult(result); }