4,390 questions
0
votes
1
answer
63
views
Difference in binding a factory returning a promise and a provider
I'm working with InversifyJS and I'm confused about when to use toFactory() and return a promise vs. toProvider(). The documentation doesn't clearly explain the behavioral differences.
In my codebase, ...
0
votes
1
answer
85
views
Making a class unittestable
My company has a large codebase. I want to make a class User unittestable with minimal changes by mocking a the MyProvider instance, which is used a lot. But it has a constructor and implements a base ...
2
votes
1
answer
64
views
Servicestack ASP.Net Core IoC
I'm using a modular ServiceStack application (with the HostingStartup attribute), so I'm registering dependencies in the ASP.NET Core built-in IoC container. In Program.cs, I'm also calling the ...
4
votes
2
answers
170
views
How to register and resolve component in Dry IoC that have self registration mechanic?
There is a service IFoo from an external library, which has its own mechanisms for registering its components. I need to register the service in the Dry IoC container, along with its additional ...
0
votes
0
answers
127
views
MEF 1 for .NET 8
I refer to MEF 1 the MEF implementation for .NET Framework. The reason I want to use it is because our .NET Framework code base already uses it. It is far from perfect or even optimal, but it is what ...
1
vote
2
answers
137
views
Autowire.BY_NAME Ambiguous argument values for parameter of type
I have 2 classes, A and B, B depends on A.
This is class A
package com.pm.spring;
public class A {
public A() {
System.out.println("Default Constructor in A");
}
}
...
1
vote
0
answers
41
views
How can I use dependency injection for a tree of stateful objects?
I’ll illustrate the issue with a simple Web application. The application code is available in GitHub. This application handles two requests:
POST /sockets/{id}/subscribe — subscribes to a socket with ...
0
votes
1
answer
47
views
Create mock for a symbol in typescript
Say I have a component:
export class Component {
constructor(@injectable(IDependency) dep: IDependency) {}
// other methods/properties do not matter
}
and the dependency it requires is defined ...
1
vote
1
answer
112
views
How to initialize a service bean with authenticated user info
I have a service that is tightly coupled with the currently authenticated user. It should receive a userId from a higher context (Controller) as an argument in one way or another. The service cannot ...
0
votes
2
answers
54
views
Spring Bean hierarchy of objects based on tenant/region
I have a spring webapp. Here's a simple structure to explain my problem
java/
└── com/
└── example/
├── controller/
│ └── MyController.java // REST Controller
├── ...
1
vote
0
answers
155
views
How to create a generic factory with injectable in Dart/Flutter?
I'm trying to come up with a scalable solution for factory registration in Dart/Flutter using injectable (or any other DI library).
Currently, I explicitly create a factory class (BarFactory) for each ...
9
votes
1
answer
4k
views
How do I Inject Dependencies in FastAPI's Lifespan Context / startup event?
I'm developing a backend service using FastAPI, and I'm facing issues with dependency injection when trying to perform data processing during the application's startup.
Here's a simplified version of ...
-1
votes
2
answers
382
views
How to use an entity in another module without creating direct dependency in SpringBoot
I have several modules in my Spring Boot application (broken with DDD in mind), which would sometimes need to depend on another module not because of logic, but because the entities are related. For ...
1
vote
2
answers
995
views
Does SpringBoot makes bean selection based on variable name?
I recently decided to play a little bit with spring's Bean injection.
I have tried to provoke my app to fail when there were two, same type, Bean definition but application started to run.
I come up ...
1
vote
0
answers
88
views
does NitroJS (server of NuxtJS) have a Dependency Injection like NestJS at the constructor level from the app singleton or perRequest?
does NitroJS (server of NuxtJS) support dependency injection as the following ?
call any dependency from the class constructor "dependency injection: inversion of control (IoC)" and let the ...
0
votes
1
answer
45
views
How to append in already created service/bean (Dict<string, List<SomeInterface>) in IOC container in dot net?
I'm working on a .NET project and adding a Dictionary<string, > to the container. Using the statement below works fine.
However, I need to initially add a few classes to this dictionary and then ...
0
votes
1
answer
288
views
I want to use express route in typescript inversify and express
I want to use custom express route in inversify with express+typescript
So code is below:
App.ts
import 'reflect-metadata';
import { InversifyExpressServer } from 'inversify-express-utils';
import { ...
0
votes
1
answer
150
views
Is the definition of "inversion of control" on wikipedia correct?
inversion of control (IoC) is a design principle in which
custom-written portions of a computer program receive the flow of
control from a generic framework.
The framework can be Java Spring ...
1
vote
2
answers
133
views
Dependency Injection with parameters
I have a WPF application. In the main window on the left is a listbox with several entries, and on the right is a ContentControl into which, when selecting one of the entries, the UserControl along ...
2
votes
2
answers
877
views
Blazor/Razor resolve components using dependency injection
I need an equivalent to dependeny injection to resolve Blazor/Razor components.
That is, I want to decouple my components in Razor Class Libraries in the exact same way that DI / IoC allows us to ...
1
vote
1
answer
83
views
Autofac: Registering a Singleton and InstancePerDependency Dependency Relationship
I'm using Autofac for dependency injection in my .NET application. I have a scenario where I want to register a service as a singleton and its dependency as InstancePerDependency. Here's a simplified ...
0
votes
1
answer
63
views
Is it possible in Castle Windsor to inject a named component without registering it explicitly?
(I use logging as an example here, but it could be any type.)
I have a multiple components that would like to write to the same log file. I know that I can resolve ILoggerFactory and get the same ...
1
vote
2
answers
442
views
Unity IOC Container. How to resolve instance from IOC container outside of the scope where container was created?
I am new to IOC containers and i am trying to understand how to use them. I understand the concept but I having issues on how to practically apply it. Currently, I am using Unity ioc container to ...
0
votes
1
answer
1k
views
Springboot 3.2.2 Failed to inject bean using @Autowire but works when changing springboot version back to 2.7.5
Hi there,
I get this error When I tried to start my main springboot class.
***************************
APPLICATION FAILED TO START
***************************
Description:
Field deptMapper in com....
0
votes
1
answer
85
views
What is the correct way to handle data access to a user-selectable file using dependency injection in a WPF MVVM application?
Consider the following situation:
A MVVM desktop GUI application where the user can create/edit a "project".
Think of a project like the Visual Studio solution: It's a file (currently an XML ...
-1
votes
2
answers
179
views
Injecting an abstract class in config file instead of instantiating with a new calss which extents it Spring Boot
I am new to the spring boot and Bean concept. My Classes are as follow:
public class PersonController {
private final AuditService<Person> auditService;
@GetMapping("/{id}/revisions&...
0
votes
0
answers
81
views
SQLite with DI freezing the UI
I am trying to implement SQLite with IOC DI in a WinUI 3 app. I have created a minimal github project that demonstrates the issue.
The UI freezes & is intermittant, it can take a while to ...
1
vote
1
answer
2k
views
My Azure service bus receiver closes due to Idle Timeout and I haven't found a way to fix it
I have a pretty basic .NET 6 app which only goal is to receive messages from Azure Service Bus and handle them. When my app works, I am pretty happy with the result and it is answering the business ...
0
votes
1
answer
305
views
Inversify child class with super method passing the argument to parent is not working
When I try to pass the argument to parent class via super class in inversify there is argument error :
"message": "The number of constructor arguments in the derived
class Child must ...
0
votes
0
answers
42
views
Springboot integrates stateless4j: Autowire get null
Dirs tree is as follow:enter image description here
I coding a statemachine with stateless4j in CTU.java of ConditionTest module, this module is used to store types.And create a springboot demo called ...
1
vote
6
answers
953
views
How to conditionally select concrete implementation for strategy pattern using Dependency Injection C#
I am trying to understand the Strategy Pattern in order to utilise it for a problem I have.
The current code looks as such where I have an amount that I want to process based on a payment type.
public ...
0
votes
1
answer
52
views
Question of lifycycle callbacks of beans in Spring
Spring documentation describes that beans managed by Ioc container are implicitly pre-instantiated by default other than specifying them as being lazy-initialized. I define a child bean definition A ...
1
vote
1
answer
4k
views
SpringApplication.run() without boot
I'm a total beginner with Spring. I'm currently trying to just run a very simple project just to start learning about Spring and understanding IoC and dependency injection. At first I created a simple ...
0
votes
1
answer
95
views
What exactly is the difference between dependency pull and contextualised dependency lookup?
I don't understand the exact difference between the dependency pull and contextualised dependency lookup.
From what I understand, dependency pull involves gathering dependencies from a registry ( ...
1
vote
2
answers
738
views
when should i use a custom configuration class in spring boot?
I am learning spring at the moment and cant figure out why and when we need to the use the custom @Configuration class and @Bean inside it as spring does everything automatically
@Configuration and @...
0
votes
1
answer
84
views
Unable to inject List property, it throws a ConversionNotSupportedException
I have two beans like this:
<alias name="defaultProblematicBean" alias="problematicBean" />
<bean id="defaultProblematicBean"
class="com.application....
0
votes
1
answer
1k
views
.NET Core 5 - Registering a class as singleton with strings in its constructor
I have a .NET 5 web application, in which I am attempting to register a particular class as a singleton instance.
I know that .NET 5 is out of support now, and there are plans to upgrade this app in ...
0
votes
1
answer
144
views
Is there a way to have a single instance of a service per an instance of another service without Owned<T>?
I'm writing a desktop application in C# and using Autofac for DI.
In my app I want to have a big service that depends on several smaller services that depend on each other. There should be only one ...
0
votes
1
answer
61
views
What's the difference between Autowire and Resouce annotations in Spring? Why I cannot substitute Resouce with Autowire?
I am trying to use Redis in Spring project. And I copied some code like this and it works well:
@Autowired
private RedisTemplate redisTemplate;
@Resource(name = "redisTemplate")
...
1
vote
0
answers
240
views
Dynamic injection based on request parameter/ header in controller using InversifyJS
I am exploring InversifyJS in TypeScript and I want to understand if InversifyJS will work for my use case.
I have a TypeScript project with serverless lambda, Koa. I want to integrate InversifyJS and ...
0
votes
1
answer
193
views
Prevent NonUniqueBeanException in Micronaut, even with using @Named annotation
Why does this code yield a io.micronaut.context.exceptions.NonUniqueBeanException?
public abstract class ObjectifyRepository<T> {
}
@Singleton
@Named("repositoryA")
public class ...
4
votes
0
answers
615
views
Binding Mapsui Map to Xaml and with MVVM and service architecture
Goal:
I try to display a map from Mapsui with MVVM and a service.
And CommunityToolkit.Mvvm is installed and can be used for the ViewModel.
My error:
Exception thrown: 'System.InvalidCastException' in ...
0
votes
0
answers
34
views
Resolve a service using Autofac
Im quite lost here guys, there's this plugin for a gameserver (https://github.com/EvolutionPlugins/Dummy/blob/openmod/Dummy/Services/DummyProvider.cs) which i need to access all the tasks from the ...
1
vote
3
answers
4k
views
What should application layer return? entity or dto?
In clean architecture, I implement restful api as an infrastructure,
the question is: what should the application layer return
1 - entity: this is what chatgpt answer, it say the application layer ...
1
vote
1
answer
262
views
Autofac RegisterInstance does not work as expected
In my ASP.NET Core application there is a IMemoryCache registration as an instance in startup. When IMemoryCache is injected into a controller, the controller receives a different instance of memory ...
1
vote
1
answer
542
views
Odd dependency injection behavior with Views & ViewModels using Template Studio for WinUI
Using Template Studio for WinUI, I created an app with 2 pages, Main and Foo. If the view model is passed into the page's constructor the application generates an exception, but if the view model is ...
2
votes
1
answer
3k
views
How to add IUserDialogs to Maui IOC Add Singleton for Acr.UserDialogs
I'm converting app to Maui. Old IOS through TinyIOC/FreshMvvm was
FreshMvvm.FreshIOC.Container.Register<IUserDialogs>(UserDialogs.Instance);
so how should that look in MauiProgram.cs using ...
1
vote
1
answer
624
views
IConfiguration DI chicken-and-egg question
I have an ASP.NET Core 7 MVC app written in C#. I want to build a custom IConfiguration to add to the providers already registered.
I would like to use some services registered in the DI service ...
1
vote
0
answers
44
views
Difficulty using DryIOC in Web form
I want use DryIoc container in web form,
I use sample code : https://github.com/dadhi/DryIoc/blob/master/docs/DryIoc.Docs/ReuseAndScopes.md#reuse-and-scopes
But every time I ask, I get a new instance ...
4
votes
2
answers
18k
views
Spring Boot error with a repository/entity, "not a managed type"
I know that similar questions have been asked before on this forum, but none of the proposed solutions helped me, so I am writing a separate question. The code is from the spring boot course on ...