/// <summary> /// Creates a new <see cref="ObjectResultExecutor"/>. /// </summary> /// <param name="formatterSelector">The <see cref="OutputFormatterSelector"/>.</param> /// <param name="writerFactory">The <see cref="IHttpResponseStreamWriterFactory"/>.</param> /// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param> /// <param name="mvcOptions">Accessor to <see cref="MvcOptions"/>.</param> public ObjectResultExecutor( OutputFormatterSelector formatterSelector, IHttpResponseStreamWriterFactory writerFactory, ILoggerFactory loggerFactory, IOptions <MvcOptions> mvcOptions) { if (formatterSelector == null) { throw new ArgumentNullException(nameof(formatterSelector)); } if (writerFactory == null) { throw new ArgumentNullException(nameof(writerFactory)); } if (loggerFactory == null) { throw new ArgumentNullException(nameof(loggerFactory)); } FormatterSelector = formatterSelector; WriterFactory = writerFactory.CreateWriter; Logger = loggerFactory.CreateLogger <ObjectResultExecutor>(); }
public ConvertViewResultToObjectResultAttributeImpl(OutputFormatterSelector formatterSelector, ILoggerFactory loggerFactory, IOptions <MvcOptions> mvcOptions, IOptions <ApiBehaviorOptions> apiBehaviorOptions, bool enabled) { _logger = loggerFactory.CreateLogger <ConvertViewResultToObjectResultAttribute>(); _mvcOptions = mvcOptions.Value; _apiBehaviorOptions = apiBehaviorOptions.Value; _enabled = enabled; }
public MiruObjectResultExecutor( OutputFormatterSelector formatterSelector, IHttpResponseStreamWriterFactory writerFactory, ILoggerFactory loggerFactory, IOptions <MvcOptions> mvcOptions) : base(formatterSelector, writerFactory, loggerFactory, mvcOptions) { }
public async Task Invoke(HttpContext context) { var aceeptHeaderEnricherContext = new AceeptHeaderEnricherContext(context, _options); foreach (var aceeptHeaderEnricher in _aceeptHeaderEnrichers.Where(a => a.CanExecute(aceeptHeaderEnricherContext))) { aceeptHeaderEnricher.Execute(aceeptHeaderEnricherContext); } var acceptHeaders = new List <MediaTypeSegmentWithQuality>(); AcceptHeaderParser.ParseAcceptHeader(context.Request.Headers[HeaderNames.Accept], acceptHeaders); context.Features.Set <IOutputFormatter>(OutputFormatterSelector.SelectFormatter(_options.Value.OutputFormatters.OfType <TextOutputFormatter>(), acceptHeaders)); await _next(context); }
public HalObjectResultExecutor( IActionResultExecutor <ObjectResult> executor, IHttpResponseStreamWriterFactory writerFactory, OutputFormatterSelector formatterSelector, ILogger <HalObjectResultExecutor> logger) { this.executor = executor ?? throw new ArgumentNullException(nameof(executor)); this.formatterSelector = formatterSelector ?? throw new ArgumentNullException(nameof(formatterSelector)); if (writerFactory == null) { throw new ArgumentNullException(nameof(writerFactory)); } this.writerFactory = writerFactory.CreateWriter; this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public async Task InvokeAsync(HttpContext context, OutputFormatterSelector selector, IHttpResponseStreamWriterFactory writerFactory ) { context.Response.StatusCode = 400; var response = new ErrorResponse { Errors = new Error[] { new Error { Code = "test", Description = "test", Meta = new Dictionary <string, object> { ["test"] = new Uri("http://go-fish") } }, } }; var formatterContext = new OutputFormatterWriteContext( context, writerFactory.CreateWriter, typeof(ErrorResponse), response); var selectedFormatter = selector.SelectFormatter(formatterContext, Array.Empty <IOutputFormatter>(), new MediaTypeCollection()); await selectedFormatter.WriteAsync(formatterContext); }
public ImageFilter(IOptions <MvcOptions> options, OutputFormatterSelector selector) { this.options = options.Value; this.selector = selector; }
public LiepaResponseWrapper(OutputFormatterSelector formatterSelector, IHttpResponseStreamWriterFactory writerFactory, ILoggerFactory loggerFactory, IOptions <MvcOptions> mvcOptions) : base(formatterSelector, writerFactory, loggerFactory, mvcOptions) { }
public QueryController(IEngine engine, IOptions <MvcOptions> options, OutputFormatterSelector selector) { this.engine = engine; this.options = options.Value; this.selector = selector; }
public ShaclController(IOptions <MvcOptions> options, OutputFormatterSelector selector) { this.options = options.Value; this.selector = selector; }