示例#1
0
 /// <summary>
 /// Configures the <paramref name="route"/> to use the given <paramref name="method"/> to add a new instance of <typeparamref name="T"/>
 /// to the data model.
 /// </summary>
 /// <typeparam name="T">A model class that implements <see cref="IApiModel"/></typeparam>
 public static IPostRoute <T> CreateUsing <T>(this IPostRoute <T> route, Action <T> method)
     where T : class, IApiModel
 {
     return(CreateUsing(((Route <T>)route), data =>
     {
         method(data);
         return data;
     }));
 }
示例#2
0
        /// <summary>
        /// Configures Fluent Web API to use a custom reply instead of its default behavior when responding to the <paramref name="route"/>.
        /// </summary>
        public static IPostRoute <T> ReplyWith <T>(this IPostRoute <T> route, Func <Responder, T, IHttpActionResult> func)
            where T : class, IApiModel
        {
            if (route == null)
            {
                throw new ArgumentNullException("route");
            }

            if (func == null)
            {
                throw new ArgumentNullException("func");
            }

            ((Route <T>)route).ReplyOnPost = func;
            return(route);
        }
示例#3
0
        /// <summary>
        /// Configures the <paramref name="route"/> to use the given <paramref name="method"/> to add a new instance of <typeparamref name="T"/>
        /// to the data model.
        /// </summary>
        /// <typeparam name="T">A model class that implements <see cref="IApiModel"/></typeparam>
        /// <returns>The model after it has been passed through the data layer, which can be useful to retrieve default values that are being set by a database, in example.</returns>
        public static IPostRoute <T> CreateUsing <T>(this IPostRoute <T> route, Func <T, T> method)
            where T : class, IApiModel
        {
            if (route == null)
            {
                throw new ArgumentNullException("route");
            }

            if (method == null)
            {
                throw new ArgumentNullException("method");
            }

            ((Route <T>)route).Creator = method;
            return(route);
        }