Beispiel #1
0
        public override object VisitCompilationUnit(CompilationUnit compilationUnit, object data)
        {
            _treeService.PushArea("Components");
            object r = base.VisitCompilationUnit(compilationUnit, data);

            _treeService.PopNode();
            return(base.VisitCompilationUnit(compilationUnit, data));
        }
Beispiel #2
0
        public void VisitCompileUnit_Always_PushesComponentsArea()
        {
            CompilationUnit cu = new CompilationUnit();

            using (_mocks.Unordered())
            {
                _treeService.PushArea("Components");
                _treeService.PopNode();
            }

            _mocks.ReplayAll();
            _visitor.VisitCompilationUnit(cu, null);
            _mocks.VerifyAll();
        }
Beispiel #3
0
        public void VisitTypeDeclaration_AControllerNoChildren_PushesAndPops()
        {
            TypeDeclaration type = new TypeDeclaration(Modifiers.Public | Modifiers.Partial, new List <AttributeSection>());

            type.Name = "SomeRandomController";

            using (_mocks.Unordered())
            {
                _treeService.PushNode(new ControllerTreeNode("SomeRandomController", "SomeNamespace"));
                _treeService.PopNode();
            }

            _mocks.ReplayAll();
            _visitor.VisitTypeDeclaration(type, null);
            _mocks.VerifyAll();
        }
Beispiel #4
0
        public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
        {
            if (!IsController(typeDeclaration))
            {
                return(null);
            }

            var area          = GetArea(typeDeclaration);
            var typeNamespace = GetNamespace(typeDeclaration);

            if (!String.IsNullOrEmpty(area))
            {
                var areas = area.Split('/');

                for (var i = 0; i < areas.Length; i++)
                {
                    var areaNode = treeService.FindNode(areas[i]) ?? new AreaTreeNode(areas[i]);

                    treeService.PushNode(areaNode);
                }
            }

            var node = IsWizardController(typeDeclaration)
                ? new WizardControllerTreeNode(typeDeclaration.Name, typeNamespace, new string[0])
                : new ControllerTreeNode(typeDeclaration.Name, typeNamespace);

            node.RestRoutesDescriptor = GetRestRoutesDescriptor(typeDeclaration);

            treeService.PushNode(node);

            var r = base.VisitTypeDeclaration(typeDeclaration, data);

            if (!String.IsNullOrEmpty(area))
            {
                var areas = area.Split('/');

                for (var i = 0; i < areas.Length; i++)
                {
                    treeService.PopNode();
                }
            }

            treeService.PopNode();

            return(r);
        }
Beispiel #5
0
        public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
        {
            if (!IsController(typeDeclaration))
            {
                return(null);
            }

            string area          = GetArea(typeDeclaration);
            string typeNamespace = GetNamespace(typeDeclaration);

            if (!String.IsNullOrEmpty(area))
            {
                string[] areas = area.Split('/');
                for (int i = 0; i < areas.Length; i++)
                {
                    TreeNode areaNode = _treeService.FindNode(areas[i]);
                    if (areaNode == null)
                    {
                        areaNode = new AreaTreeNode(areas[i]);
                    }
                    _treeService.PushNode(areaNode);
                }
            }

            ControllerTreeNode node = IsWizardController(typeDeclaration)
                                                        ? new WizardControllerTreeNode(typeDeclaration.Name, typeNamespace, new string[0])
                                                        : new ControllerTreeNode(typeDeclaration.Name, typeNamespace);

            _treeService.PushNode(node);

            object r = base.VisitTypeDeclaration(typeDeclaration, data);

            if (!String.IsNullOrEmpty(area))
            {
                string[] areas = area.Split('/');
                for (int i = 0; i < areas.Length; i++)
                {
                    _treeService.PopNode();
                }
            }
            _treeService.PopNode();

            return(r);
        }