public static ITypedBuilder WithContent <TContent>(this ITypedBuilder builder, Func <TContent> contentFactory, Encoding encoding, string mediaType) { if (contentFactory == null) { throw new ArgumentNullException(nameof(contentFactory)); } builder.WithConfiguration(s => { s.WithDefiniteContentType(typeof(TContent)); if (!typeof(IEmptyRequest).IsAssignableFrom(typeof(TContent))) { s.ContentFactory = () => contentFactory(); } }); builder.Advanced.WithContentEncoding(encoding); builder.Advanced.WithMediaType(mediaType); return(builder); }
public static ITypedBuilder WithErrorType <TError>(this ITypedBuilder builder) { return(builder.WithConfiguration(s => s.WithDefiniteErrorType(typeof(TError)))); }
public static ITypedBuilder WithDefaultResult <TResult>(this ITypedBuilder builder, Func <TResult> resultFactory) { return(builder.WithConfiguration( s => s.WithResultType(typeof(TResult)).DefaultResultFactory = t => resultFactory())); }