Ejemplo n.º 1
0
        // Create new instance of the link for the new resource type.
        internal override ActionLink CreateCopyFor <TNewResourceType>()
        {
            var newResourceLink = new ActionUrlLink();

            CopyTo <TNewResourceType>(newResourceLink);
            return(newResourceLink);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a list of ActionUrlLinks from a list of ActionMethodInfo instances describing a set of controller
        /// action methods found based on conventions.  These links can be returned to the client and used to invoke
        /// the corresponding action method.
        /// </summary>
        /// <param name="source">The action method information used to generate action links.</param>
        /// <returns>Link metadata used to generate resource specific links.</returns>
        public static IEnumerable <ActionUrlLink> ToActionLink(this IEnumerable <ActionMethodInfo> source)
        {
            var validConventionBasedHttpMethods = new[] { HttpMethod.Post.Method, HttpMethod.Delete.Method };

            foreach (ActionMethodInfo methodInfo in source)
            {
                ActionUrlLink actionLink = null;
                if (methodInfo.IdentityParamValue != null)
                {
                    actionLink = new ActionUrlLink(methodInfo.IdentityParamValue);
                }
                else if (methodInfo.Methods.Any(m => validConventionBasedHttpMethods.Contains(m)))
                {
                    actionLink = new ActionUrlLink();
                }

                if (actionLink != null)
                {
                    actionLink.Action     = methodInfo.ActionMethodName;
                    actionLink.Controller = methodInfo.ControllerName;
                    actionLink.Methods    = methodInfo.Methods;

                    yield return(actionLink);
                }
            }
        }
Ejemplo n.º 3
0
 public ActionUrlSelector(ActionUrlLink link, LambdaExpression action)
 {
     _action = action;
     _link   = link;
 }