/// <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 IGetByIdRoute <T, TKey> ReplyWith <T, TKey>(this IGetByIdRoute <T, TKey> route, Func <Responder, TKey, IHttpActionResult> func) where T : class, IApiModel <TKey> { if (route == null) { throw new ArgumentNullException("route"); } if (func == null) { throw new ArgumentNullException("func"); } ((Route <T, TKey>)route).ReplyOnGetWithId = (r, o) => func(r, (TKey)o); return(route); }
/// <summary> /// Configures the <paramref name="route"/> to use the given <paramref name="func"/> to retrieve an instance of <typeparamref name="T"/>, /// identified by a key value of type <typeparamref name="TKey"/>. /// </summary> /// <typeparam name="T">A model class that implements <see cref="IApiModel"/></typeparam> /// <typeparam name="TKey">The type of the key that identifies the model</typeparam> public static IGetByIdRoute <T, TKey> ReadUsing <T, TKey>(this IGetByIdRoute <T, TKey> route, Func <TKey, T> func) where T : class, IApiModel <TKey> { if (route == null) { throw new ArgumentNullException("route"); } if (func == null) { throw new ArgumentNullException("func"); } ((Route <T, TKey>)route).ItemRetriever = o => func((TKey)o); return(route); }