Esempio n. 1
0
 public static IList<RouteInfo> TreeStructureToList(RouteInfo routeInfo)
 {
     var result = new List<RouteInfo> {routeInfo};
     foreach (var route in routeInfo.Children)
     {
         result.Add(TreeStructureToList(route));
     }
     return result;
 }
 public override ICollection<RouteInfo> Process(ControllerTypesList controllerTypesList)
 {
     var collection = new List<RouteInfo>();
     foreach (var ct in controllerTypesList)
     {
         var attribute = (AreaRootControllerAttribute) ct.Attribute;
         var ri = new RouteInfo(attribute.Name);
         collection.Add(ri);
     }
     return collection;
 }
Esempio n. 3
0
        public void GetRouteNameTest()
        {
            _controller = "_controllerType";
            _action = "Action";
            _area = "Area";
            RouteInfo info = new RouteInfo(_area) { Controller = _controller, Action = _action };
            StringAssert.AreEqualIgnoringCase(_area + _controller + _action, info.GetRouteName());

            _childaction = "ChildAction";
            _childcontroller = "ChildController";
            var childInfo = new RouteInfo(info) {Controller = _childcontroller, Action = _childaction};
            StringAssert.AreEqualIgnoringCase(info.GetRouteName() + _childcontroller+_childaction, childInfo.GetRouteName());
        }
Esempio n. 4
0
        public static RouteInfo TransformControllersToRouteInfo(IEnumerable<Type> types, Type controllerType, string namespaceName=null)
        {
            var lookup = GetOrderedAttributes(types, controllerType, namespaceName);
            // root route
            var routeInfo = new RouteInfo();
            foreach (var keyValuePair in lookup)
            {
                var list = keyValuePair.Value;
                routeInfo.Update(list.Attribute.Process(list));
            }

            return routeInfo;
        }
Esempio n. 5
0
        public void GetRoutesHierarchyTest()
        {
            RouteInfo info = new RouteInfo {Controller = InfoControllerName};
            var testRoute = new RouteInfo {Controller = TestControllerName};
            var testRouteA = new RouteInfo {Controller = TestAControllerName};
            info.Children.Add(testRoute);
            info.Children.Add(testRouteA);

            var list = testRoute.TreeStructureToList();
            Assert.AreEqual(1, list.Count);
            StringAssert.AreEqualIgnoringCase(list[0].Controller, testRoute.Controller);

            var listA = testRouteA.TreeStructureToList();
            Assert.AreEqual(1, listA.Count);
            StringAssert.AreEqualIgnoringCase(listA[0].Controller, testRouteA.Controller);

            var infoList = info.TreeStructureToList();
            Assert.AreEqual(3, infoList.Count);
        }
Esempio n. 6
0
 public RouteInfo(RouteInfo parent)
     : this()
 {
     Parent = parent;
 }