Пример #1
0
 /// <summary>
 /// If the check returns <c>true</c>, <see cref="ValidationException"/>
 /// is emitted as an error with the given status code.
 /// Otherwise the given value is emitted.
 /// </summary>
 /// <typeparam name="TSource">The type of the value.</typeparam>
 /// <param name="observable">The parent observable.</param>
 /// <param name="invalidCheck">The invalidCheck function.</param>
 /// <param name="statusCode">The status code of the error.</param>
 /// <param name="error">The error to be used on a failed check.</param>
 /// <returns>An instance of <see cref="IProviderObservable{TSource}"/>.</returns>
 public static IProviderObservable <TSource> InvalidWhenAsync <TSource>(
     this IProviderObservable <TSource> observable,
     Func <Task <bool> > invalidCheck,
     int statusCode,
     object error) =>
 observable.InvalidWhenAsync(s => invalidCheck(), statusCode, s => error);
Пример #2
0
 /// <summary>
 /// If the check returns <c>true</c>, <see cref="ValidationException"/>
 /// is emitted as an error with the status code 400 (Bad Request).
 /// Otherwise the given value is emitted.
 /// </summary>
 /// <typeparam name="TSource">The type of the value.</typeparam>
 /// <param name="observable">The parent observable.</param>
 /// <param name="invalidCheck">The invalidCheck function.</param>
 /// <param name="error">The error to be used on a failed check.</param>
 /// <returns>An instance of <see cref="IProviderObservable{TSource}"/>.</returns>
 public static IProviderObservable <TSource> BadRequestWhenAsync <TSource>(
     this IProviderObservable <TSource> observable,
     Func <Task <bool> > invalidCheck,
     object error) =>
 observable.InvalidWhenAsync(
     s => invalidCheck(), StatusCodes.Status400BadRequest, s => error);
 /// <summary>
 /// If the check returns <c>true</c>, <see cref="ValidationException"/>
 /// is emitted as an error with the status code 404 (Not Found).
 /// Otherwise the given value is emitted.
 /// </summary>
 /// <typeparam name="TSource">The type of the value.</typeparam>
 /// <param name="observable">The parent observable.</param>
 /// <param name="invalidCheck">The invalidCheck function.</param>
 /// <param name="errorFactory">The error factory method.</param>
 /// <returns>An instance of <see cref="IProviderObservable{TSource}"/>.</returns>
 public static IProviderObservable <TSource> NotFoundWhenAsync <TSource>(
     this IProviderObservable <TSource> observable,
     Func <Task <bool> > invalidCheck,
     Func <TSource, object> errorFactory = null) =>
 observable.InvalidWhenAsync(
     s => invalidCheck(), StatusCodes.Status404NotFound, errorFactory);
Пример #4
0
 /// <summary>
 /// If the check returns <c>true</c>, <see cref="ValidationException"/>
 /// is emitted as an error with the status code 400 (Bad Request).
 /// Otherwise the given value is emitted.
 /// </summary>
 /// <typeparam name="TSource">The type of the value.</typeparam>
 /// <param name="observable">The parent observable.</param>
 /// <param name="invalidCheck">The invalidCheck function.</param>
 /// <param name="errorFactory">The error factory method.</param>
 /// <returns>An instance of <see cref="IProviderObservable{TSource}"/>.</returns>
 public static IProviderObservable <TSource> BadRequestWhenAsync <TSource>(
     this IProviderObservable <TSource> observable,
     Func <TSource, Task <bool> > invalidCheck,
     Func <TSource, object> errorFactory = null) =>
 observable.InvalidWhenAsync(invalidCheck, StatusCodes.Status400BadRequest, errorFactory);
 /// <summary>
 /// If the check returns <c>true</c>, <see cref="ValidationException"/>
 /// is emitted as an error with the status code 404 (Not Found).
 /// Otherwise the given value is emitted.
 /// </summary>
 /// <typeparam name="TSource">The type of the value.</typeparam>
 /// <param name="observable">The parent observable.</param>
 /// <param name="invalidCheck">The invalidCheck function.</param>
 /// <param name="error">The error to be used on a failed check.</param>
 /// <returns>An instance of <see cref="IProviderObservable{TSource}"/>.</returns>
 public static IProviderObservable <TSource> NotFoundWhenAsync <TSource>(
     this IProviderObservable <TSource> observable,
     Func <TSource, Task <bool> > invalidCheck,
     object error) =>
 observable.InvalidWhenAsync(invalidCheck, StatusCodes.Status404NotFound, s => error);