Esempio n. 1
0
 public void NamespaceAdder(string s, BestandInfo output)
 {
     if (s.Contains("namespace "))
     {
         output.Namespace = s.Substring(s.IndexOf("namespace") + 10).Trim().Split(new char[] { '{' }, StringSplitOptions.None)[0];
     }
 }
Esempio n. 2
0
        public void ReadUntilNextMatchingBrace(string code, BestandInfo output)
        {
            int tellerKlassen = 0;
            int nOpen         = 0;
            int indexOpen;
            int indexClose;

            do
            {
                indexOpen = code.IndexOf("{");
                if (indexOpen == -1)
                {
                    indexOpen = code.Length;
                }
                indexClose = code.IndexOf("}");
                if (indexOpen < indexClose)
                {
                    nOpen++;
                    code = code.Substring(indexOpen + 1);
                }
                if (indexOpen > indexClose)
                {
                    nOpen--;
                    code = code.Substring(indexClose + 1);
                }
                CheckStringsAndAnalyse(code, output, ref tellerKlassen);
            }while (nOpen > 0);
        }
Esempio n. 3
0
 public void ClassAdder(string s, BestandInfo output)
 {
     if (s.Contains(" class "))
     {
         TypeOffClass(s, output);
         output.Name = s.Substring(s.IndexOf("class") + 6).Trim().Split(chars, StringSplitOptions.None)[0];
     }
     else if (s.Contains(" interface "))
     {
         TypeOffClass(s, output);
         output.Name = s.Substring(s.IndexOf("interface") + 10).Trim().Split(chars, StringSplitOptions.None)[0];
     }
 }
Esempio n. 4
0
        public void CodeTeller(string path, BestandInfo output)
        {
            int teller = 0;

            foreach (string s in File.ReadAllLines(path))
            {
                if (s.Trim().Length > 0)
                {
                    teller++;
                }
            }
            output.AantalLijnenCode = teller;
        }
Esempio n. 5
0
 public void TypeOffClass(string s, BestandInfo output)
 {
     if (s.Contains(" class "))
     {
         if (s.Contains("abstract "))
         {
             output.TypeOfClass = "abstract class";
         }
         else
         {
             output.TypeOfClass = "class";
         }
     }
     if (s.Contains(" interface "))
     {
         output.TypeOfClass = "interface";
     }
 }
Esempio n. 6
0
 public void IterateFilesAndAnalyse(string folderPath)
 {
     foreach (string f in Directory.GetFiles(folderPath))
     {
         if (f.Contains(".cs"))
         {
             string      code   = File.ReadAllText(f).Replace('\r', ' ').Replace('\n', ' ');
             BestandInfo output = new BestandInfo();
             NamespaceAdder(code, output);
             ReadUntilNextMatchingBrace(code, output);
             if (output.Name != null && output.Namespace != null)
             {
                 CodeTeller(f, output);
                 Output.WriteOutputToFile(Path.GetFileNameWithoutExtension(folderPath), output);
             }
         }
     }
 }
Esempio n. 7
0
        public void WriteOutputToFile(string foldernaam, BestandInfo output)
        {
            string path = Path.Combine(OutputFolder, foldernaam, $"Analyse{foldernaam}");

            File.AppendAllText(path, output.ToString());
        }
Esempio n. 8
0
 public void CheckStringsAndAnalyse(string s, BestandInfo output, ref int tellerKlassen)
 {
     KlassenTeller(s, ref tellerKlassen);
     ClassAdder(s, output);
 }