Skip to main content
Filter by
Sorted by
Tagged with
2 votes
1 answer
64 views

Is using IServiceProvider impactful with base controller in .NET

Is it good practice to pass service provider to our controller ? Method No 1 : [Authorize] public abstract partial class BaseSecureController : Controller { private readonly IServiceProvider ...
Hakuna's user avatar
  • 491
1 vote
1 answer
84 views

What does serviceLocator() mean in GetIt?

I am trying to master GetIt. First I read the official documentation. Then I came to articles by different authors. Finally, I took a working code to get some practice. And I don't understand the ...
Texter's user avatar
  • 159
0 votes
2 answers
386 views

Using scoped services (ie DbContext) from two scopes without service locator

I need to write some service with method that needs to perform two units of work, where second one will be preformed even if first failed and was rolled back. Creating and rolling back transaction is ...
Alpedar's user avatar
  • 1,344
-2 votes
1 answer
191 views

What are bad sides of using Symfony's ServiceLocator? [closed]

The college told me that sometimes I overuse ServiceLocator in Symfony 5.4 project. I never considered that possibility. Everything seems straightforward => you get services from the container as ...
Zeljko Miloradovic's user avatar
0 votes
1 answer
734 views

Hive adapters and boxes with Get_it how should i regester them into getit

I have always issues with hive boxies instances and the error of not initilizing the box or adapter so I decided to register them in one place and use it all over place .but I don't event know how to ...
Abolfazl Mashhadi's user avatar
1 vote
1 answer
2k views

Symfony - How do I get services dynamically from the container?

For an API project I want to fail very early, before the controller is dispatched, if the input data is incorrect. I've managed to get the validation done by using the route defaults and an event ...
floriank's user avatar
  • 25.7k
2 votes
1 answer
877 views

My .NET 7 app is unable to resolve the service for a type. Already added scoped to DI

If I already registered the service in DI what am I missing? Error: System.InvalidOperationException: Unable to resolve service for type 'Contoso.API.Services.AccountService' while attempting to ...
user3191574's user avatar
1 vote
1 answer
135 views

how can i use jar of another project in my project at run-time in spring-boot without mentioning it to the pom.xml of my project

I want to create a project in spring boot in module pattern, there are four modules in my project moduleA, moduleB, moduleC and moduleD. moduleB contains the a interface. moduleC and moduleD contains ...
hunter's user avatar
  • 11
1 vote
1 answer
165 views

Combining dependency injection with service locator

In the following example, a service locator is used to inject dependencies over classes. Is that in any way better approach than resolving dependencies within the class and keep the initialiser (or ...
Ondrej Rafaj's user avatar
  • 4,417
0 votes
1 answer
791 views

Unable to use Get It background callback

I have a flutter app that has a background listener but I keep getting an Unhanded exception. Here is my main() Future<void> main() async { WidgetsFlutterBinding.ensureInitialized(); ...
Haider Malik's user avatar
  • 1,771
0 votes
2 answers
2k views

Object/factory with type DataServiceManager is not registered inside GetIt

Hello I'm currently building a Over Complicated Todo flutter app and I came across this error: E/flutter (25502): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: 'package:...
aaron dalao's user avatar
0 votes
2 answers
313 views

Creating <interface, imiplementation> map/container in C++11?

Is there a way in C++11, to create a container with map of interfaces as key and implementation classes as value of that key. What I want to do, is to be able to bind interfaces with certain ...
Piotr Aahahhkja's user avatar
3 votes
0 answers
1k views

Flutter: General confusion about dependency injection, service locator, get_it, provider and bloc

Assumptions(please check, I am probably stupid): As far as I read, the Dependency Injection Pattern and the Service Locator Pattern, are both 2 ways to achieve Inversion of Control. The package '...
Johnson's user avatar
  • 75
15 votes
5 answers
20k views

how can I route using GoRouter in Flutter without context?

The problem I want to solve: My app which uses GoRouter needs to be able to route to a named route from within main(). Since most routing is of the form 'context.go' I cannot do so within main. ...
satchel's user avatar
  • 547
0 votes
0 answers
512 views

Make bloc instances global across a Flutter app and access them by some identifier in a dependency injected fashion way

I have multiple model objects delivered by some data source in my Flutter app, each is identified by its ID (an integer field). Each model and its state can be represented in multiple widget. I'm ...
Ahmad Hamwi's user avatar
0 votes
1 answer
218 views

How can we use service locator in custom flutter library or package?

I want to split my app into features and each feature in a package, so how can we apply dependency injection using get_it in each package individually "each package represent a feature containing ...
Shehab Aladawy's user avatar
0 votes
1 answer
1k views

how to solve getit shared preferences error?

I'm trying bloctesting for my project and getting the following error: 'package:get_it/get_it_impl.dart': Failed assertion: line 372 pos 7: 'instanceFactory != null': Object/factory with type ...
Nik's user avatar
  • 337
0 votes
0 answers
236 views

Spring framework customize ServiceLocatorFactoryBean with complex type

I am trying to customize the way we use service locator pattern to have more complex type @Configuration public class VehicleConfig { @Bean public FactoryBean<?> factoryBean() { ...
Ravi's user avatar
  • 13
4 votes
1 answer
695 views

Passing dependencies the "right way"

When injecting dependencies into a constructor, I'm not quite sure if it breaks SOLID if I do the following: public MyClass(IConfiguration configuration) { _port = configuration.GetValue("...
Dan Fran's user avatar
0 votes
1 answer
2k views

How get_it flutter package deals with Garbage Collector as it registers all the instance at start

I have a naive question, I have read about the flutter dependency injection package get_it, it registers all the instances at start like the service locator design pattern, my question is how it ...
Majid's user avatar
  • 203
0 votes
0 answers
39 views

How to overcome cyclic dependency of IEnumerable without Service Locator or Lazy<T>? [duplicate]

I have a dependency of IEnumerable<ITransform> which is used like this class A { public A(IEnumerable<ITransform> transforms) {...} } I have a bunch of ITransform implementations that I ...
xakpc's user avatar
  • 1,809
2 votes
3 answers
631 views

Use a specific instance of a class inside an isolate

I am using an isolate through the compute() method to fetch, parse and sort datas from an API (around 10k entries). My method getAllCards() is defined inside a class YgoProRepositoryImpl which has an ...
Guillaume Roux's user avatar
1 vote
1 answer
2k views

Flutter/Dart get_It singleton locator method failure

I have a simple dart class as follows: import 'package:flutter/material.dart'; class UiUtils { // TEMPORARY FOR UNIT TEST PURPOSES ONLY int addition(int x, int y) { return x + y; } } (Note:...
greysqrl's user avatar
  • 977
0 votes
1 answer
443 views

Avoid Service locator in strategy design pattern [closed]

Take a look on that pseudocode class A,B,C implements StrategyInterface { private dep; constructor(Dep dep) { this->dep = dep; } } class StrategyResolver { private ...
colorgreen's user avatar
2 votes
1 answer
2k views

How to use get_it for Provider.of<ExampleProvider>(context)?

I am new to flutter and I am trying to use get_it package for DI. I want to understand how can I replace my dependance on the Inherited Widget with get_it. My code looks like this: I have a locator ...
Sharmin Khan's user avatar
5 votes
1 answer
949 views

Can't initialized GraphQl Client in flutter using Get_it

I want to implement GraphQL client in my flutter app. For Dependency injection, I use GetIt library. But when I run the app, it says 'Invalid argument (Object of type HomeGraphQLService is not ...
Aminul Haque Aome's user avatar
0 votes
0 answers
45 views

Inversion of Control and deep dependencies

[Edited to narrow down the question scope]: For simplicity sake, I have a Winforms application: main function opens FormA FormA has a button that creates and opens FormB FormB needs to send something ...
dotVlad's user avatar
6 votes
2 answers
3k views

can't initialized Shared Pref using GetIt in flutter

I want to implement a session management system using Shared Preference in my flutter app. For Dependency injection, I use GetIt library. But when I run the app, it says 'flutter: Error while creating ...
Aminul Haque Aome's user avatar
0 votes
1 answer
152 views

Converting an unruly dependency injection model with a service locator

I've been using DI for a game engine project for a while and I just hit a wall; given the below order of creation: The job system does not depend on anything and everything depends on the file logger. ...
Casey's user avatar
  • 10.9k
0 votes
1 answer
759 views

Is calling IServiceProvider.CreateScope from within a Hosted Service an anti-pattern?

Recently I have been looking at the following StackOverflow question. There is an answer there suggesting a read at Microsoft's documentation and especially the paragraph Consuming a scoped service in ...
Efthymios Kalyviotis's user avatar
1 vote
0 answers
75 views

Is there a way to copy or clone Koin scope as new scope instance?

Using Koin library I'm trying to achive this behaviour: val scopeA = getScope(ID) val scopeB = scopeA.clone() Short speaking, clone() should copy all instances from one scope to another. So in this ...
Artem's user avatar
  • 73
1 vote
0 answers
992 views

Flutter Null property in viewmodel using provider and get_it

Im developing a user authentication flow in flutter using firebase auth. I have the basis of the app which allows user login, home, password reset however i'm stuck while developing a profile screen ...
PowerMan2015's user avatar
  • 1,418
1 vote
1 answer
1k views

C# ASP.NET Core alternative to an extension method to register services

I have a problem with my AspNet Core application, I had an extension method to register configurations, on an external library, as in the example: public static AuthenticationBuilder AddSaml2PIdP(this ...
pampua84's user avatar
  • 862
4 votes
3 answers
5k views

How can I register the async object to get_it package without making the main() async?

I want to register the SharedPrefrences object in the get_it package to access it from all around the app and not make the main() async. Is it the right way? How can I do it? This is how I did it, ...
Hossein Yousefpour's user avatar
-1 votes
2 answers
99 views

C++ general question on OOP Design, how to access member of object in the top of hierarchy from bottom

I have a Class A, in the class there is some important member (lets call it someVeryImportantNumber) and also objects of class B. In class B there are objects of class C and so on..., similar to a ...
Miroslav Krajcir's user avatar
2 votes
0 answers
374 views

SolrNet - Using Dependency injection doesnt call the Startup.Init<T> method

Using Solrnet in my .NET core project through dependency injection as - services.AddSolrNet<T>("http://localhost:8983/solr"); And injecting it through ISolrOperations<T> As ...
Sahil Chawla's user avatar
1 vote
0 answers
728 views

Resolution of IServiceProvider Services Lifetime within Injected Instance

In my asp.net core I would like to inject IServiceProvider into conroller and resolve services explicitly. What is the lifetime of the resolved services? Are they scoped in the controller's OR totally ...
Roi Shabtai's user avatar
  • 3,075
0 votes
1 answer
1k views

ServiceLocator with Autofac in asp.net core 3.1

I'm developing an asp.net core 3.1 webapi application and i'm using Autofac as DI container. For one particular case i cannot use ConstructorInjection nor propertyinjection nor methodinjection. My ...
simone_Vin's user avatar
7 votes
3 answers
10k views

Flutter - Using GetIt with BuildContext

I'm using Localizations in my app based on the flutter documentation. See here: https://flutter.dev/docs/development/accessibility-and-localization/internationalization I use get_it package (version 4....
Ricky's user avatar
  • 623
4 votes
0 answers
200 views

Proguard: how to proguard META-INF/services interface and impl names?

Proguard: how to proguard META-INF/services interface and impl names for service loader? e.g. META-INF/services/com.example.Foo com.example.impl.FooImpl Is there a way for proguard to obfuscate the ...
eastwater's user avatar
  • 5,488
0 votes
0 answers
396 views

How to implement DI in Xamarin Forms w/o using a Service Locator pattern?

When I do DI in MVC, I can do it without out using a service locator pattern in any of my own code. However, as I understand it, under the hood there is a service locator pattern that's already being ...
BVernon's user avatar
  • 3,707
0 votes
2 answers
860 views

Spring service locator without autowiring it

Having this code: public class ClassA { private InterfaceB interfaceB; private int a private int b; public ClassA(int a, int b) { this.a = a; this.b = b; } } ...
MABC's user avatar
  • 595
1 vote
2 answers
988 views

Problem with JNDI look-up in WildFly 17: java.lang.ClassCastException: class is in unnamed module of loader

I use Wildfly 17 and have a couple of stateless EJBs, one of which causes me sometimes ( but not always) problems upon JNDI lookup. This is my EJB: @Stateless public class AVeDBService { //other ...
Alex Mi's user avatar
  • 1,459
15 votes
2 answers
8k views

Flutter Bloc state change is not updated UI with get_it

I've been building a login/authentication feature using a combination of this login tutorial and the resocoder clean architecture tutorials. It's 99% working perfectly, but it is not responding ...
Gary Frewin's user avatar
0 votes
2 answers
1k views

How to handle very long XPATH? Is there any alternative for this?

emphasized text //div[@class='preheader']//following-sibling::table/tbody/tr[7]/td/table[1]/tbody/tr/td/table/tbody/tr/td/table/tbody/tr/td/table/tbody/tr/td/table/tbody/tr[4]/td/table/tbody/tr/td[1]/...
gopal agarwal's user avatar
1 vote
1 answer
901 views

Koin: Why after myObject.scope.close(), it still works?

I have a scope scope<MyObject> { scoped { Presenter() } } Then when I get presenter, this works. val presenter = myObject.scope.get<Presenter>(Presenter::class.java) Similarly, ...
Elye's user avatar
  • 59.7k
0 votes
1 answer
831 views

How to move from ServiceLocator to Dependency Injection? Specific example

The problem is moving from the ServiceLocator anti-pattern to Dependency Injection. In view of my inexperience, I can't shift the DI principle to the code implemented now. Summary The Summary ...
Viewed's user avatar
  • 1,403
0 votes
1 answer
2k views

C# .net core conditional construction of dependency objects

I am creating a ASP.NET Core Rest API application. On Controller, depending upon the value of parameter we need to create request processor {job of the processor is to further process the request and ...
Posto's user avatar
  • 7,540
0 votes
0 answers
283 views

Store a Unity Dependency Injection Container without Service Locator

I have an application that has lots of external dependencies on hardware systems. I want to unit test the services that interact with these hardware systems so I am abstracting the external portion of ...
Saul Zetler's user avatar
1 vote
0 answers
209 views

How to create a library that uses DI inside and use in a project that doesn't use DI?

Hy guys, I need to create a library in a project, which uses DI internally, like that: Library namespace Library { public class SomeService : ISomeService { private readonly ...
Danilo Costa's user avatar

1
2 3 4 5
9