dependency-injection

HttpClient DelegatingHandler unexpected life cycle

瘦欲@ 提交于 2020-12-04 19:57:30
问题 In ASP.NET Core 2.1 app I am making REST request using HttpClient . I am using DelegatingHandler s to define some common behavior. The registration i here: private static void AddRestServiceDataClient<TTypedHttpClient, TTypedHttpClientImpl>(this IServiceCollection services) where TTypedHttpClient : class where TTypedHttpClientImpl : RestServiceDataClient, TTypedHttpClient { var httpClientBuilder = services .AddHttpClient<TTypedHttpClient, TTypedHttpClientImpl>() .AddHttpMessageHandler

Dependency injected services used in a new task

不羁的心 提交于 2020-12-02 07:19:06
问题 I'm using dependency injection to access my services when needed but i'm now wanting to create a concurrent task but this is causing issues due to dependency injected objects and their lifetimes. I've read this article (Heading: Prevents multi-threading): Link And from that, I've gathered that this isn't possible. My objective is to let the client send a request to begin a job that could take longer than the connection timeout of the client, thus I want to have an endpoint that initiates a

Dependency injected services used in a new task

有些话、适合烂在心里 提交于 2020-12-02 07:18:26
问题 I'm using dependency injection to access my services when needed but i'm now wanting to create a concurrent task but this is causing issues due to dependency injected objects and their lifetimes. I've read this article (Heading: Prevents multi-threading): Link And from that, I've gathered that this isn't possible. My objective is to let the client send a request to begin a job that could take longer than the connection timeout of the client, thus I want to have an endpoint that initiates a

Dependency injected services used in a new task

为君一笑 提交于 2020-12-02 07:18:04
问题 I'm using dependency injection to access my services when needed but i'm now wanting to create a concurrent task but this is causing issues due to dependency injected objects and their lifetimes. I've read this article (Heading: Prevents multi-threading): Link And from that, I've gathered that this isn't possible. My objective is to let the client send a request to begin a job that could take longer than the connection timeout of the client, thus I want to have an endpoint that initiates a

CQRS - Executing Commands within Commands

眉间皱痕 提交于 2020-12-01 11:12:32
问题 I recently saw some code scenarios where CommandHandlers were being injected with ICommandExecutor to call other commands. So commands within commands. This was also true for some QueryHandlers being injected with IQuery. public class UpdateCarDetailsCommandHandler : CommandHandler<UUpdateCarDetailsCommand> { private ICommandExecutor _command; public UpdateCarDetailsCommandHandler (ICommandExecutor command) { _command = command; } public override void Execute(UpdateCarDetailsCommand command)

CQRS - Executing Commands within Commands

不想你离开。 提交于 2020-12-01 11:12:04
问题 I recently saw some code scenarios where CommandHandlers were being injected with ICommandExecutor to call other commands. So commands within commands. This was also true for some QueryHandlers being injected with IQuery. public class UpdateCarDetailsCommandHandler : CommandHandler<UUpdateCarDetailsCommand> { private ICommandExecutor _command; public UpdateCarDetailsCommandHandler (ICommandExecutor command) { _command = command; } public override void Execute(UpdateCarDetailsCommand command)

Way to inject angular FormBuilder service to dynamic component

别来无恙 提交于 2020-11-28 09:16:59
问题 I'm trying to inject the FormBuilder service to a dynamic component this way: Template: ... <div #vc></div> ... Component: @ViewChild('vc', { read: ViewContainerRef }) _container: ViewContainerRef; ... constructor(private fb: FormBuilder, private componentFactoryResolver: ComponentFactoryResolver, private _compiler: Compiler, private _injector: Injector, private _m: NgModuleRef<any>) { } ... ngAfterViewInit() { let allPms: any[] = null; let template = ''; // construct template on the fly

Spring @Value always gives an error if property is Integer

元气小坏坏 提交于 2020-11-28 08:11:58
问题 I am using sprin version 4.3.8.RELEASE. also i am using @Value to inject values from property file, if the properties are string that no problem, but if the property is Integer that is a problem (i know there is many questions about this i tried all the answers but the issue still exist) The property is CONNECTION.TIME.OUT=100000 First solution @Value("${CONNECTION.TIME.OUT}") protected Integer connectionTimeOut; Ecxeption Failed to convert value of type 'java.lang.String' to required type

Spring @Value always gives an error if property is Integer

浪尽此生 提交于 2020-11-28 08:11:23
问题 I am using sprin version 4.3.8.RELEASE. also i am using @Value to inject values from property file, if the properties are string that no problem, but if the property is Integer that is a problem (i know there is many questions about this i tried all the answers but the issue still exist) The property is CONNECTION.TIME.OUT=100000 First solution @Value("${CONNECTION.TIME.OUT}") protected Integer connectionTimeOut; Ecxeption Failed to convert value of type 'java.lang.String' to required type