Пример #1
0
        private RouteSegment getRouteSegment(string segment, int index)
        {
            RouteSegment rs = new RouteSegment();
            rs.Index = index;
            rs.Segment = segment;
            var match = Regex.Match(segment, _routeRoleMatchString, RegexOptions.IgnoreCase);
            if (match != null)
            {

                if (match.Success)
                {
                    string value = match.Groups["name"].Value.ToLower();
                    if (value == "controller" || value == "action")
                    {
                        rs.SegmentType = SegmentType.Role;
                        rs.RouteNames.Add(value);
                    }
                    else
                    {
                        rs.SegmentType = SegmentType.Parameter;
                        rs.RouteNames.Add(value);
                    }
                }

            }

            setSegmentRole(rs);

            return rs;
        }
Пример #2
0
        private void setSegmentRole(RouteSegment segment)
        {
            if (segment.SegmentType == SegmentType.Role)
            {
                StringBuilder segmentRoleBuilder = new StringBuilder(segment.Segment);

                foreach (var routeName in segment.RouteNames)
                {
                    string oldRoleName = string.Format("{{{0}}}", routeName);
                    segmentRoleBuilder.Replace(oldRoleName, _segmentRoleMatchString);
                }

                segment.Role = segmentRoleBuilder.ToString();
            }
        }
Пример #3
0
        private void setSegmentRole(RouteSegment segment)
        {
            if (segment.SegmentType == SegmentType.Role)
            {
                StringBuilder segmentRoleBuilder = new StringBuilder(segment.Segment);

                foreach (var routeName in segment.RouteNames)
                {
                    string oldRoleName = string.Format("{{{0}}}", routeName);
                    segmentRoleBuilder.Replace(oldRoleName, _segmentRoleMatchString);
                }

                segment.Role = segmentRoleBuilder.ToString();

            }
        }