problem about simple-injector-Collection of common programming errors
qujck
c# dependency-injection ioc-container simple-injector
I have this code:using (container.BeginLifetimeScope()) {RenderWord instruction = new RenderWord();var instances = container.GetAllInstances<IInstructionHandler<RenderWord>>();var firstInstance = result.First(); }instances is of type IEnumerable<IInstructionHandler<RenderWord>>firstInstance is of type IInstructionHandler<RenderWord> that in reality is an instance of a decorator that decorates another decorator that decorates another decorator …At runtime the actua
Steven
c# .net dependency-injection quartz.net 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 achievepublic class JobImplementation: IJob {private readonly IInjectedClass injectedClass;public JobImplementation(IInjectedClass _injectedClass){injectedClass = _injectedClass}public void Execute(IJobExecutionContext _context){//Job code}
Steven
c# dependency-injection inversion-of-control simple-injector
Can I register initializers for Generic types with SimpleInjector at runtime? (see the last line of code below)public class BootStrapper {Type baseTypeGeneric = typeof(Sample<>);public void BootStrap(Container container){var types =from type in Assembly.GetExecutingAssembly().GetTypes()where type.Namespace == “NS.xyz” select type;foreach (Type type in types){Type baseType = baseTypeGeneric.MakeGenericType(type);if (type.BaseType == baseType){container.Register(type);}//how do I get this li
David
c# .net dependency-injection simple-injector webformsmvp
I’m trying to combine SimpleInjector with WebFormsMvp.To facilitate DI WebFormsMvp provides the IPresenterFactory interface. It contains the Create method which provides the presenter type to resolve and the view instance. I need to inject the view instance into the constructor of the presenter. The presenter also has other dependencies that need creating by the container.This is what I got so far, but it is not ideal. What’s the correct solution for the problem?Presenter constructor:public FooP
ADNow
entity-framework dependency-injection simple-injector
I am trying to switch to Simple Injector Dependency Injection framework as I am impressed with its speed.private static void RegisterServices(Container container){container.RegisterPerWebRequest<IDbContext, DbContext1>();////container.RegisterPerWebRequest<IDbContext, DbContext2>(); container.RegisterPerWebRequest<IUnitOfWork, UnitOfWork>();container.RegisterPerWebRequest<IColourRepository, ColourRepository>();where DbContext1 and DbContext2 inherit from a BaseDbContex
Steven
asp.net-mvc entity-framework dependency-injection ninject simple-injector
Simple Inject is throwing the following exception when attempting to register my DbContext. The supplied connection string is not valid, because it contains insufficient mapping or metadata information.Parameter name: connectionStringI’m new to DI and could be missing something fairly obvious. The connection string looks fine. It is the same one that gets used to create the DbContext normally. I was attempting the solution herepublic static class SimpleInjectorInitializer {/// <summary>Ini
Steven
.net architecture dependency-injection simple-injector
I have an Entity Framework application connecting to an SQL server on a separate box. The program flow can be broken down in to two states:Init the composition root and register types using the Simple Injector DI framework Init application (does some reads and writes with the SQL database using Entity Framework) Based on a timer, a task function gets an instance for a command that is due to run ICommandHandler<CommandType> (command types vary) Calls Handle(commandType) on this instance to
Web site is in building