Пример #1
0
        public MainWindow()
        {
            var testFile      = new FileInfo("C:\\Users\\Justin\\Desktop\\roslyn\\Src\\Compilers\\CSharp\\Portable\\CSharpExtensions.cs");
            var codeRetriever = new FileStringRetriever(testFile);
            var code          = codeRetriever.GetString();

            var results = new CSharpSlocAnalyser()
                          .GetSlocFor(code);

            var whitespace = results.WhiteSpaceLines
                             .ConvertToString();

            var comments = results.CommentLines
                           .ConvertToString();

            var directives = results.CompilerDirectiveLines
                             .ConvertToString();

            var braces = results.CurlyBraceLines
                         .ConvertToString();

            var other = results.OtherLines
                        .ConvertToString();

            var numClasses = results.NumberOfClasses;

            var numMethods = results.NumberOfMethods;

            InitializeComponent();
        }
Пример #2
0
        private void Open()
        {
            var fbd = new FolderBrowserDialog();

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                Directory = fbd.SelectedPath;
                Files.Clear();

                var files   = GetFiles(Directory);
                var results = new List <SlocResult>();
                foreach (var file in files)
                {
                    var code = new FileStringRetriever(file)
                               .GetString();
                    var result = new CSharpSlocAnalyser()
                                 .GetSlocFor(code);
                    var fileVm = new FileViewModel
                    {
                        Filename = file.Name
                    };
                    fileVm.Stats.Fill(result);
                    Files.Add(fileVm);
                    results.Add(result);
                }

                Project = new ProjectViewModel
                {
                    RootDirectory = Directory
                };
                Project.Stats.Fill(results);
            }
        }