Пример #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // get directory
            var directory = VisualStudioProvider.TryGetSolutionDirectoryInfo();

            string[] dirs = Directory.GetDirectories(directory.FullName, "*.Entities", SearchOption.AllDirectories);
            txtProjectName.Text = directory.Name;
            textBox3.Text       = directory.Name + "Context";
            foreach (string dir in dirs)
            {
                textBox2.Text = dir + @"\Concrete\";
            }

            DirectoryInfo entityInfo = new DirectoryInfo(textBox2.Text);

            foreach (var item in entityInfo.GetFiles())
            {
                comboBox1.Items.Add(item.Name.Replace(".cs", ""));
            }

            if (directory != null)
            {
                textBox1.Text = directory.FullName;
            }
        }
        private void ListBoxFill()
        {
            listBox1.Items.Clear();
            var directory = VisualStudioProvider.TryGetSolutionDirectoryInfo();

            string[] files = Directory.GetFiles(directory.FullName + @"\WebAPI\wwwroot\Upload");
            foreach (string file in files)
            {
                if (file.EndsWith(".jpg") || file.EndsWith(".jpeg") || file.EndsWith(".png"))
                {
                    listBox1.Items.Add(file);
                }
            }
        }
Пример #3
0
        public void ManagerDisposed()
        {
            var current      = System.AppDomain.CurrentDomain.BaseDirectory;
            var solutionpath = VisualStudioProvider.TryGetSolutionDirectoryInfo(current);

            string[]      files      = Directory.GetFiles(solutionpath.FullName, "*.cs", SearchOption.AllDirectories);
            const Int32   BufferSize = 128;
            List <string> lines      = new List <string>();
            int           countAll   = 0;


            foreach (string file in files)
            {
                string filename = Path.GetFileNameWithoutExtension(file);
                if (filename.EndsWith("Tests"))
                {
                    continue;
                }
                if (filename.EndsWith("Test"))
                {
                    continue;
                }
                if (filename.StartsWith("Test"))
                {
                    continue;
                }
                if (filename.Contains("UiTestController"))
                {
                    continue;
                }

                using (var fileStream = File.OpenRead(file))
                    using (var streamReader = new StreamReader(fileStream, Encoding.UTF8, true, BufferSize))
                    {
                        string regexPatternManager = @"(new.*Manager\(\))";
                        string regexPatternDispose = @".Dispose\(\)";

                        String line;
                        int    count = 0;

                        //bool found = false;
                        lines = new List <string>();
                        while ((line = streamReader.ReadLine()) != null)
                        {
                            count++;

                            if ((Regex.IsMatch(line, regexPatternManager) &&
                                 !line.Trim().StartsWith("using") &&
                                 !line.Trim().StartsWith("*") &&
                                 !line.Trim().StartsWith("/") &&
                                 !line.Trim().Contains("AbstractTaskManager") &&
                                 !line.Trim().Contains("XmlSchemaManager") &&
                                 !line.Trim().Contains("OutputDataManager") &&
                                 !line.Trim().Contains("SubmissionManager") &&
                                 !line.Trim().Contains("ImportMetadataStructureTaskManager") &&
                                 !line.Trim().Contains("EasyUploadTaskManager") &&
                                 !line.Trim().Contains("TaskManager") &&
                                 !line.Trim().Contains("base(")) ||
                                (Regex.IsMatch(line, regexPatternDispose) && !line.Contains("guow")))
                            {
                                bool isInit = false;
                                //check if its a start or end pattern
                                if ((Regex.IsMatch(line, regexPatternManager) && !line.Trim().StartsWith("using")))
                                {
                                    isInit = true;
                                }

                                if (isInit)
                                {
                                    lines.Add(count + " :\t" + line);
                                }
                                else
                                {
                                    //example

                                    /**
                                     * var dm = new DatasetManager();
                                     *
                                     * dm.dispose();
                                     */

                                    //e.g line = dm.dispose();
                                    var name = line.Split('.')[0];
                                    name = name.Trim();
                                    if (name.Contains('?'))
                                    {
                                        name = name.Replace("?", string.Empty);
                                    }

                                    for (int i = 0; i < lines.Count; i++)
                                    {
                                        var l = lines[i];
                                        if (l.Contains(name))
                                        {
                                            lines.RemoveAt(i);
                                        }
                                    }
                                }
                            }
                        }

                        //write lines from file to output
                        if (lines.Any())
                        {
                            countAll += lines.Count;

                            Debug.WriteLine(file);
                            Debug.WriteLine("-------------------------------");
                            foreach (var l in lines)
                            {
                                Debug.WriteLine(l);
                            }

                            Debug.WriteLine("++++++++++++++++++++++++++++++++");
                        }
                    }
            }

            Debug.WriteLine("********************");
            Debug.WriteLine("open: " + countAll);
            Debug.WriteLine("********************");
        }