private static IEnumerable <RouteAttribute> GetRouteAttributes(MethodInfo actionMethod,
                                                                       RouteConventionAttribute convention)
        {
            var attributes = new List <RouteAttribute>();

            // Add convention-based attributes
            if (convention != null)
            {
                attributes.AddRange(convention.GetRouteAttributes(actionMethod));
            }

            // Add explicitly-defined attributes
            attributes.AddRange(actionMethod.GetCustomAttributes <RouteAttribute>(false));

            return(attributes.OrderBy(a => a.Order));
        }
        private static string GetRoutePrefix(MethodInfo actionMethod, RouteConventionAttribute convention)
        {
            // Return an explicitly defined route prefix, if defined
            var routePrefixAttribute = actionMethod.DeclaringType.GetCustomAttribute <RoutePrefixAttribute>(true);

            if (routePrefixAttribute != null)
            {
                return(routePrefixAttribute.Url);
            }

            // Otherwise, if this is a convention-based controller, get the convention-based prefix
            if (convention != null)
            {
                return(convention.GetDefaultRoutePrefix(actionMethod));
            }

            return("");
        }
예제 #3
0
        private static ICollection<RouteDefaultAttribute> GetDefaultAttributes(MethodInfo actionMethod, string routeName,
            RouteConventionAttribute convention)
        {
            var defaultAttributes = new List<RouteDefaultAttribute>();

            // Yield explicitly defined default attributes first
            defaultAttributes.AddRange(
                from defaultAttribute in actionMethod.GetCustomAttributes<RouteDefaultAttribute>(false)
                where !defaultAttribute.ForRouteNamed.HasValue() ||
                      defaultAttribute.ForRouteNamed == routeName
                select defaultAttribute);

            // Yield convention-based defaults next
            if (convention != null)
                defaultAttributes.AddRange(convention.GetRouteDefaultAttributes(actionMethod));

            return defaultAttributes.ToList();
        }
        private static ICollection <RouteDefaultAttribute> GetDefaultAttributes(MethodInfo actionMethod, string routeName,
                                                                                RouteConventionAttribute convention)
        {
            var defaultAttributes = new List <RouteDefaultAttribute>();

            // Yield explicitly defined default attributes first
            defaultAttributes.AddRange(
                from defaultAttribute in actionMethod.GetCustomAttributes <RouteDefaultAttribute>(false)
                where !defaultAttribute.ForRouteNamed.HasValue() ||
                defaultAttribute.ForRouteNamed == routeName
                select defaultAttribute);

            // Yield convention-based defaults next
            if (convention != null)
            {
                defaultAttributes.AddRange(convention.GetRouteDefaultAttributes(actionMethod));
            }

            return(defaultAttributes.ToList());
        }
예제 #5
0
        private static string GetRoutePrefix(MethodInfo actionMethod, RouteConventionAttribute convention)
        {
            // Return an explicitly defined route prefix, if defined
            var routePrefixAttribute = actionMethod.DeclaringType.GetCustomAttribute<RoutePrefixAttribute>(true);
            if (routePrefixAttribute != null)
                return routePrefixAttribute.Url;

            // Otherwise, if this is a convention-based controller, get the convention-based prefix
            if (convention != null)
                return convention.GetDefaultRoutePrefix(actionMethod);

            return "";
        }
예제 #6
0
        private static IEnumerable<RouteAttribute> GetRouteAttributes(MethodInfo actionMethod,
                                                                      RouteConventionAttribute convention)
        {
            var attributes = new List<RouteAttribute>();

            // Add convention-based attributes
            if (convention != null)
                attributes.AddRange(convention.GetRouteAttributes(actionMethod));

            // Add explicitly-defined attributes
            attributes.AddRange(actionMethod.GetCustomAttributes<RouteAttribute>(false));

            return attributes.OrderBy(a => a.Order);
        }
        private static string GetRoutePrefix(RoutePrefixAttribute routePrefixAttribute, MethodInfo actionMethod, RouteConventionAttribute convention)
        {
            // Return an explicitly defined route prefix, if defined
            if (routePrefixAttribute != null)
            {
                return(routePrefixAttribute.Url);
            }

            // Otherwise, if this is a convention-based controller, get the convention-based prefix
            if (convention != null)
            {
                return(convention.GetDefaultRoutePrefix(actionMethod));
            }

            return(null);
        }
예제 #8
0
        private static string GetRoutePrefix(RoutePrefixAttribute routePrefixAttribute, MethodInfo actionMethod, RouteConventionAttribute convention)
        {
            // Return an explicitly defined route prefix, if defined
            if (routePrefixAttribute != null)
                return routePrefixAttribute.Url;

            // Otherwise, if this is a convention-based controller, get the convention-based prefix
            if (convention != null)
                return convention.GetDefaultRoutePrefix(actionMethod);

            return null;
        }