Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

Questions tagged [dependency-injection]

Design pattern to reduce coupling between components, by dynamically injecting into a software component dependencies that it needs to function.

2
votes
0answers
57 views

Create an isolated dependency scope with “overrides” in Asp.Net Core

Some of the classes in my multi-tenant Asp.Net Core application depend on database repositories which in turn depend on a delegate called GetCurrentTenantKey. In ...
1
vote
0answers
45 views

Include Serilog sink requiring dependency before dependency injection in .NET Core

Here is a rundown of the situation This is a .Net Core (2.1) application with a console and web front ends. For simplicity this question focuses only on the console end although the web end has the ...
-2
votes
0answers
65 views

Blog Article retrieval using DI/IoC concepts

This code implements getting a single record from the database for a system to read and manage blog posts. QUESTION: This seems to work okay in general even though the implementation seems to be ...
0
votes
0answers
29 views

Class to create and send a PDF form with attached documents

I'm currently working on building a class to create a PDF form application with attached documents and sending that file to an endpoint in Box Api. I have found extremely difficult managing ...
3
votes
0answers
79 views

Auto register Func<T> for .net core dependecy injection

The default .net core dependency injection doesn't support building Func<> for injection automatically, see question. I wrote an extension method to go find all the Func in register types ...
3
votes
0answers
58 views

One interface for multiple CRUD resources

I asked about an abstraction layer for accessing files (link) a couple of days ago (I decided to not call it a follow-up anymore as there are too many changes). I tried to incorporate many of the ...
9
votes
3answers
189 views

Multiple file access abstractions

When using dependency injection for nearly everything it's good to have some file access abstraction. I find the idea of ASP.NET Core FileProvider nice but not sufficient for my needs so inspired by ...
3
votes
0answers
57 views

Override prototype inside of constructor of ES6 class for dependency injection

We implemented a small dependency injection mechanism which we use in our project. Now after 2 years of developing our project we need our classes to know who instantiated them via dependency ...
3
votes
1answer
72 views

Instantiating View Models using a static factory

I am building an e-commerce website. I have an application layer service called SearchService. SearchService receives a search ...
3
votes
0answers
55 views

Testing application stability by throwing random diagnostic exceptions

I'd like to be able to better test application stability. Usually when you're doing this, you run the application and keep your fingers crossed that it won't crash when an error occurs (be it a ...
2
votes
0answers
56 views

GUI to control a NZXT cooling and lighting system

I am working since a couple of weeks on my first Python application and I would love to have a review of the code I wrote so far. The app has the purpose of controlling the cooling and lighting of an ...
1
vote
0answers
54 views

Dependency resolver in PHP

I wrote a simple Dependency Resolver in PHP that I'm hoping to get some input on. The main problem that gave me some trouble was when it had to resolve typed arguments ( like type hinting a ...
2
votes
0answers
55 views

Dependency Inversion in constructor

Currently I'm learning OOP and meanwhile I'm trying to keep the SOLID principles. Is it right to inject dependency (GenName - generate file name) on File ...
1
vote
0answers
105 views

Xamarin Forms with Ninject navigation service

I am new to Xamarin Forms and I have been searching online finding ways to set up navigation in a MVVM fashion. In particular I am designing around a concept I found here. However, I am using Ninject ...
1
vote
2answers
393 views

Creating an instance of an unit of work (NHibernate)

I'm trying to figure out how to create a NHibernate UnitOfWork using .NET Core Dependency Injection. I was just hard-coding the ...
0
votes
1answer
33 views

Manager that collects and handles multiple tasks that run on events like window.scroll, window.resize etc

I'm working on a website where different things can occur on resize and scroll events. I only want one event handler that comes ...
3
votes
1answer
178 views

Socket server in c#

I'm writing a socket server for a project I am working on. I'm used to working in .NET FW, but I'm attempting to write this using .NET standard/core. Particularly, I am concerned about managing ...
0
votes
0answers
58 views

Inject settings as a dependency, and serve them using a Web API

I used an opportunity to learn about Dependency Injection and DDD, therefore, althought any feedback is welcome, I am interested in feedback about those software design principles. I have a small ...
1
vote
2answers
136 views

Mandatory dependency in a class

I have a class with some mandatory properties which I set via constructor, like this (properties omitted for sake of simplicity): ...
3
votes
1answer
364 views

API client, using an injectable helper to aid testing

description write a api client that fetch items from remote service I have separated Service{} class's helper methods into another class ...
6
votes
1answer
176 views

The Last Lost Bubble Shooter - a Board game for children

In this game the pieces are trains and you move forward on the track (never backwards) in search of your goal. The players move based on a combination of resources (Soap and Water to make Bubbles) ...
1
vote
0answers
197 views

Show mobile SoundCloud player in WebView

Demo for a SoundCloud player in WebView for specific song or artist stream as a workaround because SoundCloud is not accepting API key request anymore. SoundCloudWebView: ...
2
votes
0answers
72 views

Centralized static factory methods with dependency injection

I am trying to make a small e-commerce backend in php. I centralized all the static factory methods in a class called EntityFactory. The main reason for that was to ...
0
votes
0answers
323 views

Dependency Injection and Service Locator/DI Container

I have implemented clean architecture for my app, and I have a few questions. Typically, pure DI is argued for over a Service Locator pattern, because it is very explicit and more testable. However, ...
2
votes
1answer
2k views

Injecting a DbContext with an async constructor dependency

The goal is to construct a DbContext with a connection that uses an access token. The access token is acquired with ADAL (Active Directory Authentication Library). ...
2
votes
1answer
185 views

Laravel Dependency Injection : Perfomace Issue And Architecture Style

I have a TransportationController which uses six repositories. The repositories are injected to the controller via constructor and method. TransportationController.php ...
2
votes
0answers
2k views

Using IServiceScopeFactory without implementing the Service Locator Pattern

I want to use IServiceScopeFactory in a way, which is not the Service Locator anti-pattern. Therefore I thought about making a generic one, which supports ...
4
votes
1answer
6k views

Adding extension methods to IServiceCollection in ASP.NET Core

I have the following extension method to add themes support to my application: ...
1
vote
0answers
60 views

Dependency injection for a bus with a stop-request display application

I have been told that my implementation below doesn't need dependency injection, however Jeffrey Way uses DI in two similar examples in this tutorial: https://laracasts.com/lessons/tell-dont-ask and ...
1
vote
1answer
53 views

Separating logic per class and being able to use dependency injection

I use Laravel, but hopefully this doesn't matter. I have a user and user's state. Say, simple integer or a string. I want to run some logic depending on user state in my service class. So, the first ...
2
votes
0answers
80 views

Find a (nearly) optimal route among several locations that can be found by Google Maps

The README should give you all of the information you need for a comprehensive review, and if it doesn't then please say so. If you would like to contribute a review but do not have time or desire to ...
6
votes
1answer
918 views

Stopwatch dependency for unit-testing

My AsyncDetector is internally using a Stopwatch to calculate time intervals. Because of this hardcoded dependency I am not able ...
4
votes
2answers
168 views

Using dependency injection for Node payment system

I would like some feedback on my code. I am currently building a payments solution in a serverless lambda project. This what I came up with (very basic code at the moment): ...
1
vote
2answers
2k views

Activator with simple dependency injection

In one of my projects I needed a simple dependency incjection activator so I've built one. It performs only type/inheritance matching because I'm not creating a second Autofac and I think I won't need ...
0
votes
1answer
81 views

Different implementation of an Interface along with additional parameters

I am designing an interface for 2 distinct implementations as follows: Perform operations without client credentials ( for my local applications) Perform operations using security token. (for web ...
2
votes
2answers
3k views

Using Autofac to do DI in a static factory method

I'm using Autofac to create one of my classes inside of a static factory method Create. This code is working and I haven't noticed any side effects yet. Admittedly, ...
4
votes
0answers
3k views

Logging in ASP.Net MVC project

I want to implement a Logger and use Serilog as Provider. My Project is ASP.NET MVC Framework (not core). Initially I tried to replicate ASP.Net Core Logging framework. I created a ...
13
votes
4answers
354 views

Constructor-injecting a truckload of commands

There's a problem in Rubberduck that we haven't neatly solved yet, and as we're exploring alternative approaches I figured I'd ask the CR community and see what our C# experts think. Here's the ...
0
votes
1answer
145 views

Dagger 2 test application

I have a complicated Dagger 2 use case on Android, where I have a lot of dependencies, but some of them are really slow to construct. Like 2-3 seconds slow. My solution was to create an RX ...
0
votes
1answer
100 views

Controller with too many parameters with DI [closed]

Is there a way to reduce the number of parameters of this constructor? All the services must be used in this Controller. The majority of them are used more than 2 times(some of them >10), with the ...
5
votes
2answers
14k views

C# - Entity Framework + Repository pattern + Unit of work pattern

After hours spent on reading various articles about correct way to implement Repository patter & UoW patters I finally think that I have managed to create (hopefully good) implementation. The ...
1
vote
1answer
826 views

CacheManager - Dependency injection

I create a cache manager to manage a system of cache exchangeable by another implementation. I use the CacheManager class throughout my program. If I want to ...
2
votes
1answer
518 views

Using constructor dependency injection in a custom mapper class

I am quite new to DI and its patterns so I decided to place my code for some review. I am working on an digital map application using .NET Core 2.0. I am using the standard DI framework of ASP.NET ...
3
votes
1answer
128 views

Google Guice module that loads two kinds of views

The code of my Guice Module looks like this: ...
2
votes
1answer
1k views

Factory using Structuremap to inject concrete implementation of BaseTask<T>

The problem statement that I am trying to solve is this; We will retrieve a list of Tasks from an external repository. These tasks will have a type and for each type, there needs to be a specific ...
0
votes
1answer
163 views

Dependency Injection tool for c++

I'm trying to create some tool for easier dependency injection in c++14, here is one of my concepts using std::tuple. ...
2
votes
1answer
209 views

PHP Dependency Injections w/ Router

I've been working on a personal from-scratch project for the purpose of learning, and so far I've been able to successfully build a DI container and a simple URI router. It works as expected right now,...
7
votes
0answers
1k views

Flask view dependency injection

so, first of all, I've been into trying to have a simple dependency container as possible in python and with your help managed to get conceive https://github.com/dareenzo/tinydic, many thanks. Now, I ...
4
votes
2answers
491 views

Process retriever for running Windows processes

I am developing a project (which purpose is not relevant for this question) where I have a class responsible for retrieving a list of running Windows processes. The implementation will basically use ...
3
votes
1answer
4k views

Full integration test for a Console application

I'm sill experimenting with different design patterns for full integration tests for Console applications (and later also Windows Services) and I wasn't quite happy with the result of the refactoring ...