Exemplo 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;
 }
Exemplo 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());
        }
Exemplo 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;
        }
Exemplo 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);
        }
Exemplo n.º 6
0
 public RouteInfo(RouteInfo parent)
     : this()
 {
     Parent = parent;
 }