Questions tagged [simple-injector]

Simple Injector is an Dependency Injection library for Microsoft .NET, .NET Core, .NET Standard, Windows Phone, Windows Store Apps, and Mono.

Simple Injector is an Inversion of Control library for the Microsoft .NET platform and supports .NET 4.0, .NET Core, .NET Standard, Silverlight, Windows Phone 8, Windows Store Apps, PCL and Mono. According to the web site, the goal of Simple Injector is to provide .NET application developers with

an easy, flexible and fast dependency injection library that uses best practice to guide your solutions toward the pit of success.

To get familiar with Simple Injector, you can go to the project's documentation wiki. It contains many subjects, such as:

References:

The Advanced scenarios section of the documentation talks about subjects such as:

Besides these references to the Simple Injector documentation there are lots of other interesting articles such as:

1070 questions
46
votes
1 answer

Simple Injector vs Hiro vs Autofac

I'm new to DI and IoC and I'm trying to decide which IoC container to learn. I've seen several performance comparisons in which the three containers referenced seem to perform very well. However, I have found no feature comparisons that included…
43
votes
2 answers

Simple Injector unable to inject dependencies in Web API controllers

I am attempting to do some basic constructor DI with Simple Injector, and it seems that it is unable to resolve the dependencies for Web API controllers. I have an API controller in an "API" folder, that is outside the "Controllers" folder. I have…
37
votes
3 answers

Constructor injection with Quartz.NET and Simple Injector

Currently I am writing a service using Quartz.NET to schedule the running of it. I was wondering if anyone has any experience of using constructor injection with Quartz.NET and Simple Injector. Below is essentially what I wish to achieve public…
Thewads
  • 4,723
  • 11
  • 54
  • 69
35
votes
6 answers

Using Simple Injector with SignalR

I thought using my own IoC would be pretty straight forward with SignalR and maybe it is; most likely I'm doing something wrong. Here's my code I have so far: private static void InitializeContainer(Container container) { …
rball
  • 6,796
  • 7
  • 45
  • 74
34
votes
3 answers

Avoiding all DI antipatterns for types requiring asynchronous initialization

I have a type Connections that requires asynchronous initialization. An instance of this type is consumed by several other types (e.g., Storage), each of which also require asynchronous initialization (static, not per-instance, and these…
25
votes
5 answers

Using Application Insights with Unit Tests?

I have an MVC web app, and I'm using Simple Injector for DI. Almost all my code is covered by unit tests. However, now that I've added some telemetry calls in some controllers, I'm having trouble setting up the dependencies. The telemetry calls…
21
votes
1 answer

Factory Interface in Simple Injector

I'm a Ninject user that try to learn Simple Injector One Ninject feture that I often use in my applications is the Factory Interface With that I can create a Interface like this: public interface IBarFactory { Bar CreateBar(); } And the register…
magol
  • 5,713
  • 15
  • 58
  • 115
18
votes
3 answers

Decorators and IDisposable

I have a subclass of DbContext public class MyContext : DbContext { } and I have an IUnitOfWork abstraction around MyContext that implements IDisposable to ensure that references such as MyContext are disposed of at the appropriate time public…
qujck
  • 13,744
  • 4
  • 40
  • 70
17
votes
4 answers

Dependency Injection (using SimpleInjector) and OAuthAuthorizationServerProvider

New to Dependency Injection, so this is probably a simple matter, but i have tried and cant figure it out, i am using Simple Injector. I have a WebApi that uses SimpleInjector perfectly fine, now i would like to implement security using OAuth. To do…
Gillardo
  • 8,447
  • 14
  • 60
  • 126
17
votes
1 answer

How to get OwinContext from Global.asax?

I am trying to set up my Dependency Injection and I am in the need of injecting a IAuthenticationManager from ASP.NET Identity to an OwinContext. For this I am from my Global.asax -> ServiceConfig.Configure() running: container.Register(() =>…
janhartmann
  • 13,440
  • 13
  • 78
  • 130
17
votes
2 answers

Does Simple Injector supports MVC 4 ASP.NET Web API?

I am new to Simple Injector IOC container. I will start working in a project which will require a Multi-tenant ASP.NET MVC implementation using MVC 4 ASP.NET Web API. My question is: Does Simple injector support MVC 4 ASP.NET Web API? Reading simple…
user1489941
  • 281
  • 4
  • 9
16
votes
2 answers

Simple Injector: Register ILogger by using ILoggerFactory.CreateLogger()

I'm working with a project which utilizes Simple Injector as dependency injector. On the other hand, this project uses Microsoft.Extensions.Logging in order to log the events that occurs in certain classes. My technical issue is pretty simple to…
16
votes
4 answers

ICommandHandler/IQueryHandler with async/await

EDITH says (tl;dr) I went with a variant of the suggested solution; keeping all ICommandHandlers and IQueryHandlers potentially aynchronous and returning a resolved task in synchronous cases. Still, I don't want to use Task.FromResult(...) all over…
mfeineis
  • 2,417
  • 17
  • 22
16
votes
1 answer

Get the container instance for Simple Injector

I am using Simple Injector with a ASP.NET MVC project. I added the SimpleInjector.Integration.Web.Mvc nuget package. This adds SimpleInjectorInitializer class in App_Start folder and initializes the DI. The code looks something like public static…
Chandermani
  • 42,177
  • 11
  • 82
  • 86
15
votes
1 answer

How can I emulate Modules / Installers / Registries with Simple Injector

Autofac has modules, Windsor has Installers and StructureMap Registries ... with Simple Injector how can I pack configuration logic into reusable classes? I have tried: public interface IModule { } public class FooModule : IModule { public…
o3o
  • 1,074
  • 13
  • 23
1
2 3
71 72