public SqlServerDataService( IConnectionStringProvider connectionStringProvider, IResponseFactory responseFactory) { ConnectionStringProvider = connectionStringProvider; ResponseFactory = responseFactory; }
/// <summary> /// constructor, create new instance of HttpSender /// </summary> /// <param name="client">System.Net.Http.HttpClient</param> /// <param name="options"></param> /// <param name="logger">Microsoft.Extensions.Logging.ILogger</param> /// <param name="responseFactory"></param> /// protected HttpSenderBase(HttpClient client, HttpSenderOptions options, IResponseFactory responseFactory, ILogger logger) { _client = client; _options = options; _logger = logger; ResponseFactory = responseFactory; }
public HandlerCaller( IRequestHandlerFactory requestHandlerFactory, IResponseFactory responseFactory) { _requestHandlerFactory = requestHandlerFactory; _responseFactory = responseFactory; }
/// <summary> /// Creates a new <see cref="IResponse{TData}"/> instance that represents /// a successful response with the specified <paramref name="data"/> /// for it's details. /// </summary> /// <typeparam name="TData">The data type for the details in a successful response.</typeparam> /// <param name="factory"><see cref="IResponseFactory"/></param> /// <param name="data">The details to assign in the successful response.</param> /// <returns><see cref="IResponse{TData}"/></returns> public static IResponse <TData> Success <TData>(this IResponseFactory factory, TData data) { return(new Response <TData> { Data = data, }); }
protected EndpointBase( IDataService dataService, IResponseFactory responseFactory) { _options = new ApiOptions(); _dataService = dataService; _responseFactory = responseFactory; }
public ClienteController( ILogger <ApiControllerBase <ClienteEntity, ClienteViewModel, ClienteViewModel, InsertClienteViewModel, UpdateClienteViewModel> > logger, IResponseFactory responseFactory, IClienteServiceApplication clienteServiceApplication) : base(logger, clienteServiceApplication, responseFactory) { _clienteServiceApplication = clienteServiceApplication; }
public DummyModelsController( ILogger <DummyModelsController> logger, IMediator mediator, IResponseFactory responseFactory) : base(logger, mediator) { this._responseFactory = responseFactory; }
public UpdatePersonUseCase(IPersonApiGateway gateway, IResponseFactory responseFactory, ISnsGateway snsGateway, ISnsFactory snsFactory) { _gateway = gateway; _responseFactory = responseFactory; _snsFactory = snsFactory; _snsGateway = snsGateway; }
public AssetsEndpoint( IDataService dataService, IResponseFactory responseFactory) : base(dataService, responseFactory) { Characters = new AssetOwner(this, "characters"); Corporations = new AssetOwner(this, "corporations"); }
public ClienteController( ILoggerFactory logger, IResponseFactory responseFactory, IClienteServiceApplication clienteServiceApplication) : base(logger, clienteServiceApplication, responseFactory) { _clienteServiceApplication = clienteServiceApplication; _clienteServiceApplication.Includes = clientes => clientes.Include(x => x.Cartoes); }
public RestClient( IHttpClientFactory clientFactory, IRequestMessageFactory requestMessageFactory, IResponseFactory responseFactory) { _clientFactory = clientFactory ?? throw new ArgumentNullException(nameof(clientFactory)); _requestMessageFactory = requestMessageFactory ?? throw new ArgumentNullException(nameof(requestMessageFactory)); _responseFactory = responseFactory ?? throw new ArgumentNullException(nameof(responseFactory)); }
public AManager() { logger = new ConsoleLogger(); _serializer = new JSONSerializer(); _imageConverter = new MyImageConverter(); responseFactory = new JSONResponseFactory(_serializer); entityFactory = new EntityFactory(); dataFactory = new DataFactoryDelegation(_serializer, logger, _imageConverter); }
public DiscoveryListener(ISocketFactory socketFactory, IResponseFactory responseFactory, IMessageParser messageParser, IDeviceInfoCollector deviceInfoCollector) { _socketFactory = socketFactory; _responseFactory = responseFactory; _messageParser = messageParser; _deviceInfoCollector = deviceInfoCollector; _stopped = true; _started = false; }
/// <summary> /// Creates a new <see cref="IResponse"/> instance that represents a /// failed response with the specified error details. /// </summary> /// <param name="factory"><see cref="IResponseFactory"/></param> /// <param name="code">A numeric <c>code</c> used to identify the error.</param> /// <param name="message">A <c>message</c> used to describe the error.</param> /// <param name="exception">The <see cref="Exception"/> which caused the error.</param> /// <returns><see cref="IResponse"/></returns> public static IResponse Error(this IResponseFactory factory, int code, string message, Exception exception) { var details = new Dictionary <string, object> { ["Exception"] = exception, }; return(Error(factory, code, message, details)); }
public AccountsController( IMediator mediator, IMapper mapper, IResponseFactory responseFactory) { this._mediator = mediator; this._mapper = mapper; this._responseFactory = responseFactory; }
/// <summary> /// Creates a new <see cref="IResponse"/> instance that represents a /// failed response for a resource that is currently locked for editing by another user. /// </summary> /// <param name="factory"><see cref="IResponseFactory"/></param> /// <param name="exception">A <see cref="DBConcurrencyException"/> that contains the details of who has the resource currently locked.</param> /// <returns><see cref="IResponse"/></returns> public static IResponse Locked(this IResponseFactory factory, DBConcurrencyException exception) { var details = new Dictionary <string, object> { ["UserId"] = exception?.Data["UserId"] as int?, ["DisplayName"] = exception?.Data["DisplayName"] as string, }; return(Error(factory, CommonStatusCodes.Locked, "The resource is currently locked for editing by another user.", details)); }
public BaseController(IMediator mediator, IMapper mapper, IResponseFactory responseFactory, IOptionsSnapshot <ApiSettings> apiSettings) { ApiSettings = apiSettings.Value; Mediator = mediator; Mapper = mapper; ResponseFactory = responseFactory; }
/// <summary> /// Creates a new <see cref="IResponse"/> instance that represents a failed response for a missing resource. /// </summary> /// <param name="factory"><see cref="IResponseFactory"/></param> /// <param name="idName">Contains the name of the Key or Id that wasn't found.</param> /// <param name="idValue">Contains the value of the Key or Id that wasn't found.</param> /// <returns><see cref="IResponse"/></returns> public static IResponse NotFound(this IResponseFactory factory, string idName, object idValue) { var details = new Dictionary <string, object> { // dictionary keys cannot be null [idName ?? "Id"] = idValue, }; return(NotFound(factory, details)); }
public GitHubResponder( IResponseFactory responseFactory, IHttpClient httpClient, IJsonSerialiser jsonSerialiser ) { this.httpClient = httpClient; this.jsonSerialiser = jsonSerialiser; this.responseFactory = responseFactory; }
/// <summary> /// Creates a new <see cref="IResponse"/> instance that represents a failed response with a list of problems describing a conflict. /// </summary> /// <param name="factory"><see cref="IResponseFactory"/></param> /// <param name="message">Contains the conflict message.</param> /// <param name="problems">A list of problems describing the conflict.</param> /// <returns><see cref="IResponse"/></returns> public static IResponse Conflict(this IResponseFactory factory, string message, IEnumerable <string> problems) { // force enumeration of the problems var collection = problems as IReadOnlyCollection <string> ?? problems?.ToArray(); var details = new Dictionary <string, object> { ["Problems"] = collection }; return(Error(factory, CommonStatusCodes.Conflict, message, details)); }
public ApiControllerBase( ILogger <ApiControllerBase <TEntity, TGetByIdDto, TGetAllDto, TInsertData, TUpdateData> > logger, IBaseServiceApplication <TEntity, TGetByIdDto, TGetAllDto, TInsertData, TUpdateData> serviceApplication, IResponseFactory responseFactory) { _logger = logger; _logger?.LogInformation($"Inicializando Controller Base<{ typeof(TEntity).Name }, Guid >"); _responseFactory = responseFactory ?? throw new ResponseFactoryNullException(); _serviceApplication = serviceApplication; }
/// <summary> /// Creates a new <see cref="IResponse"/> instance that represents a /// failed response with the specified error details. /// </summary> /// <param name="factory"><see cref="IResponseFactory"/></param> /// <param name="code">A numeric <c>code</c> used to identify the error.</param> /// <param name="message">A <c>message</c> used to describe the error.</param> /// <returns><see cref="IResponse"/></returns> public static IResponse Error(this IResponseFactory factory, int code, string message) { return(new Response { Error = new ErrorData { Code = code, Message = message, }, }); }
public CommandService( ICommandValidator commandValidator, IControlConnectionPool connectionPool, IResponseFactory responseFactory, ILogger <CommandService>?logger = null) { CommandValidator = commandValidator; ConnectionPool = connectionPool; ResponseFactory = responseFactory; Logger = logger ?? NullLogger <CommandService> .Instance; }
public ImporterController( IValidator validator, IResponseFactory responseFactory, ICsvImporterService csvImporterService, IJobsService jobsService) { _validator = validator; _responseFactory = responseFactory; _csvImporterService = csvImporterService; _jobsService = jobsService; }
public PersonApiController(IGetByIdUseCase getByIdUseCase, IPostNewPersonUseCase newPersonUseCase, IUpdatePersonUseCase updatePersonUseCase, ITokenFactory tokenFactory, IHttpContextWrapper contextWrapper, IResponseFactory responseFactory) { _getByIdUseCase = getByIdUseCase; _newPersonUseCase = newPersonUseCase; _updatePersonUseCase = updatePersonUseCase; _tokenFactory = tokenFactory; _contextWrapper = contextWrapper; _responseFactory = responseFactory; }
public async Task <IResponse <T> > Send <T>(IRequest request, CancellationToken token = default) { if (token == null) { token = DefaultCancellationTokenSource().Token; } using (HttpRequestMessage requestMessage = await request.MessageBuilder.Build()) { HttpResponseMessage responseMessage = await HttpClientBuilder.HttpClient.SendAsync(requestMessage, token); IResponseFactory responseFactory = request.MessageBuilder.CreateResponseFactory(); return(await responseFactory.Create <T>(responseMessage)); } }
/// <summary> /// Creates a new <see cref="IResponse"/> instance that represents a /// failed response with the specified error details. /// </summary> /// <param name="factory"><see cref="IResponseFactory"/></param> /// <param name="code">A numeric <c>code</c> used to identify the error.</param> /// <param name="message">A <c>message</c> used to describe the error.</param> /// <param name="details">Optionally contains any details for the error.</param> /// <returns><see cref="IResponse"/></returns> public static IResponse Error(this IResponseFactory factory, int code, string message, IEnumerable <KeyValuePair <string, object> > details) { var detailsDictionary = details as IDictionary <string, object> ?? details?.ToDictionary(pair => pair.Key, pair => pair.Value); return(new Response { Error = new ErrorData { Code = code, Message = message, Details = detailsDictionary, }, }); }
/// <summary> /// Creates a new <see cref="IResponse"/> that represents a failed /// response for a bad request due to model state validation errors. /// </summary> /// <param name="factory"><see cref="IResponseFactory"/></param> /// <param name="modelState">The <see cref="ModelStateDictionary"/> which contains the model validation errors.</param> /// <returns><see cref="IResponse"/></returns> public static IResponse BadRequest(this IResponseFactory factory, ModelStateDictionary modelState) { if (modelState == null) { throw new ArgumentNullException(nameof(modelState)); } if (modelState.IsValid) { throw new InvalidOperationException(); } // the SerializableError for a ModelStateDictionary is really a IDictionary<string, string[]> var errors = new SerializableError(modelState) .ToDictionary(pair => pair.Key, pair => (string[])pair.Value); return(factory.BadRequest(errors)); }
public async Task Invoke(HttpContext httpContext, IResponseFactory responseFactory) { try { await this._next(httpContext); } catch (Exception exception) { this._logger.LogError(exception, exception.Message); var(statusCode, responseMessage) = this.GetResponseValuesFromException(exception); httpContext.Response.ContentType = "application/json"; httpContext.Response.StatusCode = statusCode; var response = responseFactory.Create(message: responseMessage); await httpContext.Response.WriteAsync(JsonSerializer.Serialize(response)); } }
public PaynovaClient(IHttpConnection connection) { Ensure.That(connection, "connection").IsNotNull(); Connection = connection; Serializer = new DefaultJsonSerializer(); CreateOrderHttpRequestFactory = new CreateOrderHttpRequestFactory(Runtime.Instance, Serializer); AuthorizeInvoiceHttpRequestFactory = new AuthorizeInvoiceHttpRequestFactory(Runtime.Instance, Serializer); InitializePaymentHttpRequestFactory = new InitializePaymentHttpRequestFactory(Runtime.Instance, Serializer); RefundPaymentHttpRequestFactory = new RefundPaymentHttpRequestFactory(Runtime.Instance, Serializer); FinalizeAuthorizationHttpRequestFactory = new FinalizeAuthorizationHttpRequestFactory(Runtime.Instance, Serializer); AnnulAuthorizationHttpRequestFactory = new AnnulAuthorizationHttpRequestFactory(Runtime.Instance, Serializer); GetAddressesHttpRequestFactory = new GetAddressesHttpRequestFactory(Runtime.Instance, Serializer); GetCustomerProfileHttpRequestFactory = new GetCustomerProfileHttpRequestFactory(Runtime.Instance, Serializer); GetPaymentOptionsHttpRequestFactory = new GetPaymentOptionsHttpRequestFactory(Runtime.Instance, Serializer); RemoveCustomerProfileCardHttpRequestFactory = new RemoveCustomerProfileCardHttpRequestFactory(Runtime.Instance, Serializer); RemoveCustomerProfileHttpRequestFactory = new RemoveCustomerProfileHttpRequestFactory(Runtime.Instance, Serializer); ResponseFactory = new GenericResponseFactory(Serializer); }
public SprintCreator(ICreatesValidators <CreateSprintRequest> validatorFactory, IGetsCurrentProject projectGetter, IEntityData sprintRepo, IGetsTransaction transactionFactory, IResponseFactory <CreateSprintResponse> responseFactory, ISprintFactory sprintFactory) { if (sprintFactory == null) { throw new ArgumentNullException(nameof(sprintFactory)); } if (responseFactory == null) { throw new ArgumentNullException(nameof(responseFactory)); } if (transactionFactory == null) { throw new ArgumentNullException(nameof(transactionFactory)); } if (sprintRepo == null) { throw new ArgumentNullException(nameof(sprintRepo)); } if (projectGetter == null) { throw new ArgumentNullException(nameof(projectGetter)); } if (validatorFactory == null) { throw new ArgumentNullException(nameof(validatorFactory)); } this.sprintFactory = sprintFactory; this.responseFactory = responseFactory; this.transactionFactory = transactionFactory; this.sprintRepo = sprintRepo; this.projectGetter = projectGetter; this.validatorFactory = validatorFactory; }
public GenerateRequestByType(IRequestFactory requestfactory, IResponseFactory responsefactory) { _requestfactory = requestfactory; _responsefactory = responsefactory; }
public HttpServerDelegate(IHttpRequestDelegate requestDelegate) { this.responseFactory = new ResponseFactory(requestDelegate); }