Category "dependency-injection"

Hilt Inject field into any class with no scope

Suppose that I have a class A class A () I want to inject an instance of A as a field into class B and let Hilt or Dagger to handle it. Class B { @Inject la

How do I use .Net Core Dependency Injection from within a custom Class

Bit of a newbie question. I am having trouble getting access to dependency injected services from within my own custom class in ASP.NET Core 3.1 I can access se

How to use HttpClientFactory with AutoRest generated client

AutoRest generated client don't have suitable constructor for use it with services.AddHttpClient() method. So how can we get around this? Now we have public co

Use dependency injection in static class

I need to use Dependency Injection in a static class. the method in the static class needs the value of an injected dependency. The following code sample demo

Dualboot Angular13 and Angular1: cannot downgrade injectable services with parameters

I have dual boot with Angular 13 and Angular 1. The app is built with webpack v5. The tsconfig has key "emitDecoratorMetadata":true. After install I run NGCC on

Why use AddScoped() instead of AddSingleton()?

Why I should use AddScoped() for my repositories or services? Why not AddSingleton()? I know about differences between them, but dont understand why I shouldn't

How to log retries from Polly with ILoggerFactory

Or: How to log from a static method. From https://github.com/App-vNext/Polly you have examples like this one where a logger is magically available: Policy .Ti

Blazor Cannot provide a value for property 'ScopeFactory' on type 'MyComponent' because the property has no setter

I'm writing Blazor WASM app in .NET 6. The app works as it should in Debug when running from Visual Studio 2022, but when I deploy it as a static site using dot

ASP.NET Core Web API - Cannot instantiate implementation type 'System.Net.Http.IHttpClientFactory' for service type

I am trying to use Dependency Injection to register service in ASP.NET Core-6 Web API. I got this interface: public interface IHttpClientService { Task<T

Blazor Server App MVVM-Pattern: Get notifyed in parent from child component change of App-State via a serviceclass in Startup.cs

I work on a Blazor-Server-App and try to follow MVVM pattern. My problem is, that I don't understand why a parentpage is not 'auto refreshed' after a property i

Apache spark, is it possible to have Google guice as dependency injection technique

Is it possible to use Google guice as dependency injection provider for a Apache spark Java application? I am able to achieve this if the execution is happening

Avoiding generic class with many type parameters, when the consumer of those types are tightly coupled

I am trying to come up with a way to do this where I can have type safety but also loose coupling of a couple of different components in my class. I am running

How to resolve a circular dependency in nest js?

I have my app.module that imports UserModule and AuthModule. @Module({ imports: [UserModule, AuthModule], controllers: [AppController], providers: [AppSer

Field mailSender .. required a bean of type 'org.springframework.mail.javamail.JavaMailSender' that could not be found

I'm currently trying to build an email registration process with an email confirmation. I use the JavaMailSender for this. Unfortunately, I am currently getting

How can I build an IOptionsMonitor<T> for testing?

For the normal IOptions interface, you can manually build an instance e.g. this SO question. Is there any equivalent way to make an IOptionsMonitor instance wi

Best strategy for creating a child container (or isolated scope) with Microsoft.Extensions.DependencyInjection

In my AspNetCore application, I process messages that arrive from a queue. In order to process a message, I need to resolve some services. Some of those service

.Net MAUI - AppShell navigation & dependency injection

I'm playing around with .Net Maui, AppShell and dependency injection. I try to call a page with a constructor which takes the ViewModel of this page as paramete

How do I register a HandlerInterceptor with constructor dependencies in Spring Boot

My use case is running custom code before a controller method by annotating methods. HandlerInterceptor seems the way to go but it seems impossible to inject d

ASP.NET Core IHostedService manual start/stop/pause(?)

I would like to implement a recurring (timed) IHostedService instance in ASPNET Core that can be stopped and started on demand. My understanding is that IHoste

ASP.NET Core IHostedService manual start/stop/pause(?)

I would like to implement a recurring (timed) IHostedService instance in ASPNET Core that can be stopped and started on demand. My understanding is that IHoste