/// <summary> /// Initializes a new instance of the <see cref="AutoResponseApiEventHttpResponseMapper"/> class. /// </summary> /// <param name="contextResolver">The context resolver.</param> /// <param name="formatter">The formatter.</param> public AutoResponseApiEventHttpResponseMapper( IContextResolver contextResolver, IAutoResponseExceptionFormatter formatter) : base(formatter) { this.contextResolver = contextResolver ?? throw new ArgumentNullException(nameof(contextResolver)); }
/// <summary> /// Initializes a new instance of the <see cref="ApiEventHttpResponseMapperBase"/> class. /// </summary> /// <param name="formatter">The formatter.</param> protected ApiEventHttpResponseMapperBase(IAutoResponseExceptionFormatter formatter) { this.formatter = formatter ?? throw new ArgumentNullException(nameof(formatter)); this.mappers = new Lazy <IDictionary <Type, Func <ExceptionHttpResponseContext, object, IHttpResponse> > >(() => { var mappersInstance = new Dictionary <Type, Func <ExceptionHttpResponseContext, object, IHttpResponse> >(); this.ConfigureMappings(new ExceptionHttpResponseConfiguration(mappersInstance)); return(mappersInstance); }); }
/// <summary> /// Converts error details to formatted validation error detials. /// </summary> /// <param name="errorDetails">The error details.</param> /// <param name="formatter">The formatter.</param> /// <returns>The formatted validation error details.</returns> public static ValidationErrorDetails ToFormatted( this ValidationErrorDetails errorDetails, IAutoResponseExceptionFormatter formatter) { return(new ValidationErrorDetails( formatter.Message(errorDetails.Message), errorDetails.Errors.Select(e => new ValidationError( formatter.Resource(e.Resource), formatter.Field(e.Field), e.Code, e.Message)))); }
/// <summary> /// Initializes a new instance of the <see cref="ExceptionHttpResponseContext"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="formatter">The formatter.</param> public ExceptionHttpResponseContext(object context, IAutoResponseExceptionFormatter formatter) { this.Context = context; this.Formatter = formatter ?? throw new ArgumentNullException(nameof(formatter)); }
/// <summary> /// Initializes a new instance of the <see cref="SampleHttpResponseMapper"/> class. /// </summary> /// <param name="contextResolver">The context resolver.</param> /// <param name="formatter">The formatter.</param> public SampleHttpResponseMapper(IContextResolver contextResolver, IAutoResponseExceptionFormatter formatter) : base(contextResolver, formatter) { }