Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
        private async Task Analize(string fullName)
        {
            //Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => ClearAllRtb()));
            var task = await Task.Factory.StartNew <bool>(() =>
            {
                MatchCollection collection = parser.regexAllMethod.Matches(File.ReadAllText(fullName));
                AllMethodsCount           += collection.Count;
                foreach (Match item in collection)
                {
                    if (!parser.regexName.IsMatch(item.Value))
                    {
                        string outs = parser.regexIncorrectName.Match(item.Value).Value;
                        try
                        {
                            if (outs.Length > 0)
                            {
                                Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => TbTitle.Document.Blocks.LastOrDefault().Background = Brushes.Coral));
                                Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => TbTitle.AppendText(item.Value + "\n")));

                                Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => TbTitle.Document.Blocks.LastOrDefault().Background = Brushes.LightGreen));
                                Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => TbTitle.AppendText("Correct name: " + char.ToUpper(outs[1]) + outs.Substring(2).Trim('(') + "\n")));
                                ErrorCount++;
                            }
                        }
                        catch { }
                    }
                    Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => TbAllMethots.AppendText(item.Value + "\n")));
                }
                collection = parser.regexAllClass.Matches(File.ReadAllText(fullName));

                foreach (Match item in collection)
                {
                    if (!parser.regexClassName.IsMatch(item.Value))
                    {
                        Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => TbTitle.Document.Blocks.LastOrDefault().Background = Brushes.Coral));
                        Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => TbTitle.AppendText(item.Value + "\n")));
                        string outs = parser.regexIncorectClassName.Match(item.Value).Value.Replace("class", "");

                        if (outs.Length > 0)
                        {
                            Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => TbTitle.Document.Blocks.LastOrDefault().Background = Brushes.LightGreen));
                            Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => TbTitle.AppendText("Correct name: " + char.ToUpper(outs[1]) + outs.Substring(2).Trim('(') + "\n")));
                        }
                        ErrorCount++;
                    }
                    Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => TbAllClasses.AppendText(item.Value + "\n")));
                }
                AllClassesCount += collection.Count;
                collection       = parser.regexAllPropety.Matches(File.ReadAllText(fullName));
                foreach (Match item in collection)
                {
                    //if (!new Regex(@"(.*)\s[A-z]\s[A-Z]([A-z]+\s)", RegexOptions.Singleline).IsMatch(item.Value))
                    //{
                    //    Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => TbTitle.Document.Blocks.LastOrDefault().Background = Brushes.Coral));
                    //    Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => TbTitle.AppendText(item.Value + "\n")));
                    //    string outs = new Regex(@"\s[a-z]([A-z]*)\s").Match(item.Value).Value;

                    //    if (outs.Length > 0)
                    //    {
                    //        Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => TbTitle.Document.Blocks.LastOrDefault().Background = Brushes.LightGreen));
                    //        Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => TbTitle.AppendText("Correct name: " + Char.ToUpper(outs[1]) + outs.Substring(2).Trim('(') + "\n")));
                    //    }
                    //    ErrorCount++;
                    //}
                    Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => TbAllProperty.AppendText(item.Value + "\n")));
                }
                Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() => FillStat()));
                return(true);
            });
        }