public ObjectRequest( [NotNull] object content, [NotNull] IRequestContentFormatter formatter, [CanBeNull] IReadOnlyDictionary <string, string> attributes = null) : this(Guid.NewGuid().ToString(), DateTimeOffset.Now, content, formatter, attributes) { }
public ObjectRequest( [NotNull] string identifier, DateTimeOffset created, [NotNull] object content, [NotNull] IRequestContentFormatter formatter, [CanBeNull] IReadOnlyDictionary <string, string> attributes = null) { _content = content ?? throw new ArgumentNullException(nameof(content)); _formatter = formatter ?? throw new ArgumentNullException(nameof(formatter)); Identifier = identifier ?? throw new ArgumentNullException(nameof(identifier)); Created = created; Attributes = attributes; }
public FormattingMiddleware(IEnumerable <IRequestContentFormatter> formatters, IRequestContentFormatter fallbackFormatter) { if (_formatters == null) { throw new ArgumentNullException(nameof(formatters)); } if (_fallbackFormatter == null) { throw new ArgumentNullException(nameof(fallbackFormatter)); } _formatters = formatters.ToDictionary(f => f.Type, f => f); _fallbackFormatter = fallbackFormatter; }
public static IRegistrar <IRequestProcessorMiddleware> AddResolveFormatter(this IRegistrar <IRequestProcessorMiddleware> builder, IEnumerable <IRequestContentFormatter> formatters, IRequestContentFormatter fallbackFormatter) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (formatters == null) { throw new ArgumentNullException(nameof(formatters)); } if (fallbackFormatter == null) { throw new ArgumentNullException(nameof(fallbackFormatter)); } return(builder.Add(ctx => new FormattingMiddleware(formatters, fallbackFormatter))); }
public static IRegistrar <IRequestProcessorMiddleware> AddResolveFormatter(this IRegistrar <IRequestProcessorMiddleware> builder, IRequestContentFormatter formatter) { return(builder.AddResolveFormatter(Enumerable.Empty <IRequestContentFormatter>(), formatter)); }