private async Task AnalyzeCodeCSharpOneFile(string fullName) { await Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => ClearAllRtb())); var task = await Task.Factory.StartNew <bool>(() => { MatchCollection collection = parser.regexClassAndComment.Matches(File.ReadAllText(fullName)); MatchCollection collectionMethods = parser.regexMethodAndComment.Matches(File.ReadAllText(fullName)); foreach (Match item in collection) { Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => TbComments.AppendText(" " + item.Value.Trim(new char[] { '{' }) + splitter))); } foreach (Match item in collectionMethods) { if (!item.Value.Contains("xaml")) { Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => TbComments.AppendText (" " + item.Value.Trim(new char[] { '{' }) + splitter))); } } Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => BtnAddFoderPath.IsEnabled = true)); return(true); }); }
private void ClearAllRtb() { TbComments.Document.Blocks.Clear(); TbAllClasses.Document.Blocks.Clear(); TbAllMethots.Document.Blocks.Clear(); TbLayout.Document.Blocks.Clear(); TbStatistics.Document.Blocks.Clear(); TbTitle.Document.Blocks.Clear(); TbAllProperty.Document.Blocks.Clear(); TbComments.AppendText("\n"); TbAllClasses.AppendText("\n"); TbAllMethots.AppendText("\n"); TbLayout.AppendText("\n"); TbStatistics.AppendText("\n"); TbTitle.AppendText("\n"); AllMethodsCount = 0; AllClassesCount = 0; ErrorCount = 0; }
private async Task <string> AnalyzeCodeCSharp(string path) { //await Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => ClearAllRtb())); path = path.Replace("\\select.this.directory", ""); path = path.Replace(".this.directory", ""); if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } TbPath.Text = path; DirectoryInfo info = new DirectoryInfo(path); directoryInfos.Add(info); BtnAddFoderPath.IsEnabled = false; var task = await Task.Factory.StartNew <bool>(() => { GetDirictories(info); foreach (var directory in directoryInfos) { foreach (FileInfo files in directory.GetFiles()) { if (files.Name.Contains("cs") && !files.Name.Contains("config") && !files.Name.Contains("csproj") && !files.Name.Contains("Designer") && !files.Name.Contains("designer") && !files.Name.Contains("Assembly")) { Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => TreeView.Items.Add(files))); MatchCollection collection = parser.regexClassAndComment.Matches(File.ReadAllText(files.FullName)); MatchCollection collectionMethods = parser.regexMethodAndComment.Matches(File.ReadAllText(files.FullName)); foreach (Match item in collection) { Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => TbComments.AppendText(" " + item.Value.Trim() + splitter))); } foreach (Match item in collectionMethods) { if (!item.Value.Contains("xaml")) { Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => TbComments.AppendText(" " + item.Value.Trim() + splitter))); } } Analize(files.FullName); } } } Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => BtnAddFoderPath.IsEnabled = true)); return(true); }); return(path); }