コード例 #1
0
 /// <summary>
 /// Wrap the received value in an <see cref="OkObjectResult"/>.
 /// <para>
 /// Catches <see cref="ValidationException"/> and converts it to
 /// an appropriate <see cref="IActionResult"/>.
 /// </para>
 /// </summary>
 /// <typeparam name="TSource">The type of the value.</typeparam>
 /// <param name="observable">The parent observable.</param>
 /// <returns>An instance of <see cref="IProviderObservable{IActionResult}"/>.</returns>
 public static IProviderObservable <IActionResult> ToOkObjectResult <TSource>(
     this IProviderObservable <TSource> observable) =>
 observable.ToActionResult(s => new OkObjectResult(s));
コード例 #2
0
 /// <summary>
 /// Wrap the received value in an <see cref="CreatedAtRouteResult"/>
 /// with status code 201 (Created).
 /// <para>
 /// Catches <see cref="ValidationException"/> and converts it to
 /// an appropriate <see cref="IActionResult"/>.
 /// </para>
 /// </summary>
 /// <typeparam name="TSource">The type of the value.</typeparam>
 /// <param name="observable">The parent observable.</param>
 /// <param name="routeValuesFactory">
 /// The factory function for the route data to use for generating the URL.
 /// </param>
 /// <returns>An instance of <see cref="IProviderObservable{IActionResult}"/>.</returns>
 public static IProviderObservable <IActionResult> ToCreatedAtRouteResult <TSource>(
     this IProviderObservable <TSource> observable,
     Func <TSource, object> routeValuesFactory) =>
 observable.ToActionResult(s => new CreatedAtRouteResult(routeValuesFactory(s), s));
コード例 #3
0
 /// <summary>
 /// Emits an <see cref="OptionsResult"/> which lists the allowed
 /// HTTP verbs.
 /// <para>
 /// Catches <see cref="ValidationException"/> and converts it to
 /// an appropriate <see cref="IActionResult"/>.
 /// </para>
 /// </summary>
 /// <typeparam name="TSource">The type of the value.</typeparam>
 /// <param name="observable">The parent observable.</param>
 /// <param name="verbsFactory">A factory function for the allowed HTTP verbs.</param>
 /// <returns>An instance of <see cref="IProviderObservable{IActionResult}"/>.</returns>
 public static IProviderObservable <IActionResult> ToOptionsResult <TSource>(
     this IProviderObservable <TSource> observable,
     Func <TSource, IEnumerable <HttpVerb> > verbsFactory) =>
 observable.ToActionResult(s => new OptionsResult(verbsFactory(s)));
コード例 #4
0
 /// <summary>
 /// Wrap the received value in an <see cref="ObjectResult"/>
 /// with status code 202 (Accepted).
 /// <para>
 /// Catches <see cref="ValidationException"/> and converts it to
 /// an appropriate <see cref="IActionResult"/>.
 /// </para>
 /// </summary>
 /// <typeparam name="TSource">The type of the value.</typeparam>
 /// <param name="observable">The parent observable.</param>
 /// <returns>An instance of <see cref="IProviderObservable{IActionResult}"/>.</returns>
 public static IProviderObservable <IActionResult> ToAcceptedObjectResult <TSource>(
     this IProviderObservable <TSource> observable) =>
 observable.ToActionResult(s => new ObjectResult(s)
 {
     StatusCode = StatusCodes.Status202Accepted,
 });
コード例 #5
0
 /// <summary>
 /// Emits <see cref="NoContentResult"/> on receiving a value. Does not contain the value.
 /// <para>
 /// Catches <see cref="ValidationException"/> and converts it to
 /// an appropriate <see cref="IActionResult"/>.
 /// </para>
 /// </summary>
 /// <typeparam name="TSource">The type of the value.</typeparam>
 /// <param name="observable">The parent observable.</param>
 /// <returns>An instance of <see cref="IProviderObservable{IActionResult}"/>.</returns>
 public static IProviderObservable <IActionResult> ToNoContentResult <TSource>(
     this IProviderObservable <TSource> observable) =>
 observable.ToActionResult(s => new NoContentResult());