예제 #1
0
        public void TestGetChildrensCountWithMonoNamespace()
        {
            Mono.CSharp.ClassB someClass = new Mono.CSharp.ClassB();
            MCSClassElement simpleElement = new MCSClassElement("someClass", someClass);
            IEnumerable<ITreeElement> childrens = simpleElement.GetChilds();

            Assert.AreEqual(3, childrens.Count());
        }
예제 #2
0
        public void TestGetChildrensCountWithSystemNamespace()
        {
            Testdata.ClassB someClass = new Testdata.ClassB();
            MCSClassElement simpleElement = new MCSClassElement("some_name", someClass);
            IEnumerable<ITreeElement> childrens = simpleElement.GetChilds();

            Assert.AreEqual(3, childrens.Count());
        }
예제 #3
0
        public void TestGetChildrensGetElementsTypes()
        {
            Mono.CSharp.ClassB someClass = new Mono.CSharp.ClassB();
            MCSClassElement simpleElement = new MCSClassElement("someClass", someClass);

            IEnumerable<ITreeElement> childrens = simpleElement.GetChilds();

            Assert.IsTrue(childrens.First() is SystemElement);
            Assert.IsTrue(childrens.Last() is MCSClassElement);
        }
예제 #4
0
        public void TestGetChildrensGetElementsNames()
        {
            Mono.CSharp.ClassB someClass = new Mono.CSharp.ClassB();
            MCSClassElement simpleElement = new MCSClassElement("someClass", someClass);

            IEnumerable<ITreeElement> childrens = simpleElement.GetChilds();

            Assert.AreEqual("aIntegerValue", childrens.First().Name);
            Assert.AreEqual("cClassAValue", childrens.Last().Name);
        }
예제 #5
0
        public void VisitMCSClassElement(MCSClassElement element)
        {
            MCSCLassElementsCount += 1;
            IEnumerable<ITreeElement> childrens = element.GetChilds();

            foreach (var child in childrens)
            {
                child.Visit(this);
            }
        }
예제 #6
0
        public void TestVisitSystemElementsCount()
        {
            MCSElementVisitor sv = new MCSElementVisitor();
            Mono.CSharp.ClassB someClass = new Mono.CSharp.ClassB();

            MCSClassElement se = new MCSClassElement("name", someClass);
            se.Visit(sv);

            Assert.AreEqual(6, sv.SystemElementsCount);
        }
예제 #7
0
        public void VisitMCSClassElement(MCSClassElement element)
        {
            if (!IsNeedProcessElement(element.ValueObject))
            {
                return;
            }

            _builder.WriteStartMCSClass(element.TypeName, element.Name);

            VisitChildrens(element);

            _builder.WriteEndMCSClass(element.TypeName);
        }
예제 #8
0
        public void TestMethod1()
        {
            Stream outputStream = File.OpenWrite("C:\\xml_output.xml");
            XMLFormatBuilder xmlBuilder = new XMLFormatBuilder(outputStream);
            FormatTextVisitor ftv = new FormatTextVisitor(xmlBuilder, null);
            xmlBuilder.WriteStartDocument();
            string _pathToTests = System.Reflection.Assembly.GetExecutingAssembly().Location;
            _pathToTests = System.IO.Path.GetDirectoryName(_pathToTests);

            string _dmcsAssemblyFullPath = System.IO.Path.Combine(_pathToTests, "dmcs.exe");

            MCSCompiler compiler = new MCSCompiler(_dmcsAssemblyFullPath, new EmptyReportPrinter());
            compiler.Compile(_pathToTests + @"\Testdata\FileWithValidSouceCode.cs");

            MCSClassElement se = new MCSClassElement("root", compiler.TreeRoot);
            se.Visit(ftv);
            xmlBuilder.WriteEndDocument();
            xmlBuilder.Close();
            outputStream.Close();
        }
        public override void Process(SourceCodeProject project)
        {
            MCSCompiler compiler = new MCSCompiler(Utils.GetDmcsAssemblyPath(), _reporter);
            if (!compiler.SuccessfulCreated)
            {
                return;
            }

            _formatter.WriteStartDocument();
            _formatter.WriteStartCustomElement("Project", "Name", project.Name);

            int filesProcessed = 0;

            DoProgress(0);

            foreach (SourceFile file in project)
            {
                if (!compiler.Compile(file.FileFullPath))
                {
                    continue;
                }

                FormatTextVisitor visitor = new FormatTextVisitor(_formatter, _processors);

                _formatter.WriteStartCustomElement("SourceFile", "Name", file.PathInProject);

                MCSClassElement root = new MCSClassElement("Root", compiler.TreeRoot);
                root.Visit(visitor);

                _formatter.WriteEndElement();

                filesProcessed++;

                DoProgress(filesProcessed * 100 / project.FilesCount);
            }

            _formatter.WriteEndElement();
            _formatter.WriteEndDocument();
        }
예제 #10
0
        public void VisitMCSClassElement(MCSClassElement element)
        {
            try
            {
                if (_visited.ContainsKey(element.ValueObject))
                {
                    return;
                }
            }
            catch
            {
                return;
            }

            _visited.Add(element.ValueObject, true);

            depth++;
            IEnumerable<ITreeElement> childrens = element.GetChilds();

            for (int i = 0; i < depth; ++i)
            {
                _writer.Write("  ");
            }

            _writer.WriteLine("Class: {0}, Name: {1}", element.TypeName, element.Name);

            foreach (var child in childrens)
            {
                child.Visit(this);
            }

            depth--;
        }