Questions tagged [dependency-injection]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
37 views

DI container with auto-wiring feature

So I decided to write my own DI container for educational purposes and would like some feedback on how I can improve the quality of my code. I'm not sure about the documentation as most of my ...
-2
votes
2answers
84 views

Episode 1: Mastering code and Testing it [closed]

Once upon a time there was a noob developer who learned it all by himself because he grew up in a nation far behind in IT. I've tried to learn C# for about 5 years, without any improvement over the ...
0
votes
1answer
72 views

Console Commands with dependency injection (C#) [closed]

So I'm writing a big server and I've made a simple start on console commands. I'm not sure if the way I'm doing it in is correct so I'd like to have it reviewed. I have a class called ...
1
vote
0answers
70 views

Dependency Injected StackExchange.Redis Client

I am currently building cache for my application, and I would like to have my redis cache client work the same way you would dependency inject a DbContext. I am using StackExchange.Redis to manage my ...
2
votes
0answers
26 views

ASP.NET Core 3.1 Web API + Pure DI

I was playing around with ASP.NET Core 3.1 and tried to implement Dependency Injection flavor called Pure DI, i.e. without dependency container (even the built in one) to instantiate Controllers. You ...
3
votes
0answers
30 views

Functional Dependency Injection Abstraction

The F# web-development framework Giraffe supports a functional style of Dependency Injection using a form of the Reader monad, as explained in this GitBook. I would like to use this pattern more ...
2
votes
1answer
90 views

C# REST / Http Client Abstraction

I have a REST library. These are the abstractions. Have I missed anything that a developer would need to use this in a dependency injection / IoC Container scenario? Anything that bothers you about ...
1
vote
1answer
48 views

A Class to Supply an Open Database Connection during the life of a Web Request

For some database requests, I like to use raw ADO.NET. In the context of a web request, I have created a class which provides an open IDbConnection object. I use ...
4
votes
0answers
81 views

Production planner

I have a class that creates an object, PlannedYear, and then passes that object into several other classes to manipulate it. The ultimate goal of the class is to ...
5
votes
0answers
90 views

Using ClientFactory-pattern with Dependency Injection

I initially posted this on Stackoverflow but was recommended to try here instead. I'm looking for feedback on why the implementation of my ClientFactory is probably bad, from a Dependency ...
8
votes
0answers
158 views

Geode Contents Predictor StardewValley Mod

The goal I really enjoy the game Stardew Valley. One of the things that the game has are geodes. Much like real-world geodes, these geodes can be cracked open, and you can find some fun things inside....
3
votes
1answer
163 views

Grouping low-level services together into a high-level service

I am working on an e-commerce website. What I need to do is to save an advertisement. The ad has some properties and some photos... properties should be save to DB and photos should be saved to file ...
3
votes
1answer
96 views

OOP Dependency inversion principle VBA

I've reproduced the example of this video where dependency inversion principle is explained by Tim Corey based on C# I had some trouble understanding the scope of the Logger and MessageSender ...
3
votes
0answers
68 views

ASP .NET Core DI: Dependency on single implementation of multiple registrations of service type

Problem I have a DI scenario where I have multiple classes that implement a common interface (IModelService). I'm using a generic framework class (...
0
votes
0answers
72 views

Extremely lightweight dependency injection

I need to have access to a set of common data inside a few functions. The data values are determined only at runtime, and are far away in terms of control flow, so handing them to the function as an ...
4
votes
2answers
115 views

C# Cryptography Interface

C# lacks a common off-the-shelf encryption and decryption interface for dependency injection. Nearly every codebase I've ever opened has a couple of extension methods for hashing strings and so on. ...
1
vote
0answers
25 views

Usage of global variable for dynamic value that must be declared compile time [closed]

I've been trying to make a work-around for global usage; however, I can't seem to find an alternative. I'd like to create a C++ suffix function which converts pixels to millimeters. A custom gui ...
1
vote
0answers
27 views

How should I instantiate a class using composition with Laravel IOC container? [closed]

I have an Analytics class that performs some actions to compile analytics data. Here is that class: ...
3
votes
0answers
45 views

HTTP Delete,Put,Get,Post REQUEST java-ee RESTful services JPA CDI EJB

I am creating introduction app to java ee and APIs of java ee and i want know if my code is ok (like its working but if it could be done better) and what should i avoid in future ...
1
vote
1answer
70 views

Creating a ModelBinder to Sanitize user input in HTML format

I have a custom model binder which takes user input in HTML format, sanitize the HTML input by removing any script or XSS threat and returns the sanitized HTML string: ...
2
votes
3answers
141 views

Simple middleware pipeline builder (similar to asp.net-core)

I created a simple middleware pipeline builder that I want to use for my frameworks. It is similar to how ASP.NET-Core middleware works and uses the same conventions: A public constructor with a ...
-1
votes
1answer
72 views

Using Dependency Injection through constructor [closed]

I am working on a asp.net mvc project. And I wonder if the setup of the project is correct. So just some advice Because I see this: ...
4
votes
2answers
108 views

Registering Named services and resolving them by T

Problem statement I have an application that needs to get files from various sources (disk, embedded, http, ftp, ...) so I use a common API for them: ...
2
votes
0answers
40 views

Swift MVVM: Repositories - loading entities and dependency injection

I create a lexikon and a navigation for ZOO. I use MVVM architecture supported by ReactiveSwift. I have a few questions about my practises and whether I could write my repositories better and more ...
1
vote
1answer
184 views

Do these BLL-DAL comply with the Dependency-Inversion Principle and is this valid Dependency Injection?

I am working on a very simplified proof of concept (POC). Separation of concerns should be achieved in this project, so that in the future we have flexibility in respect of what data source we use (...
3
votes
0answers
59 views

Using functional interface arguments in methods of services injected via Spring

Here is the working code for my Spring service: ...
1
vote
0answers
51 views

Tightly coupled Basic Authentication Filter

I have an asp.net web api and I would like to use basic authentication. Is there any way to make this loosely coupled? I tried constructor DI but I couldn't figure it out how to pass Dbcontext into ...
0
votes
0answers
32 views

Business logic refactoring needed

I am using asp.net web API and EF code first. I am querying the database based on values inside of the request object (initiate). If there are results, I am updating the database. Then I am querying ...
0
votes
2answers
66 views

Wrapper class for system dialog to allow for dependency injection

The following class is a wrapper for Microsoft.Win32.SaveFileDialog. I've implemented the usage of Microsoft.Win32.SaveFileDialog...
2
votes
0answers
266 views

Ninject binding for Dbcontext

I have an asp.net web API and I am using EF6 to connect to a third party rest API which sells online game codes. We made a deal with the company so clients have to call my rest API in order to get the ...
4
votes
3answers
90 views

Dependency injection in constructor vs Supplying argument in utility functions

I have the following: ...
2
votes
0answers
106 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 ...
2
votes
1answer
717 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 ...
5
votes
0answers
332 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 ...
4
votes
0answers
86 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 ...
8
votes
3answers
518 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
66 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
110 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
208 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
61 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
57 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
222 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
768 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
352 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
63 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
177 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
366 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 ...
7
votes
1answer
291 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) ...
2
votes
0answers
251 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: ...

1 2 3 4 5