예제 #1
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 IGetRoute <T> ReplyWith <T>(this IGetRoute <T> route, Func <Responder, IHttpActionResult> func)
            where T : class, IApiModel
        {
            if (route == null)
            {
                throw new ArgumentNullException("route");
            }

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

            ((Route <T>)route).ReplyOnGet = func;
            return(route);
        }
예제 #2
0
        /// <summary>
        /// Configures the <paramref name="route"/> to use the given <paramref name="func"/> to retrieve an <see cref="IEnumerable{T}"/> of <typeparamref name="T"/>.
        /// </summary>
        /// <typeparam name="T">A model class that implements <see cref="IApiModel"/></typeparam>
        public static IGetRoute <T> ReadUsing <T>(this IGetRoute <T> route, Func <IEnumerable <T> > func)
            where T : class, IApiModel
        {
            if (route == null)
            {
                throw new ArgumentNullException("route");
            }

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

            ((Route <T>)route).CollectionRetriever = func;
            return(route);
        }