simple-injector

what's the purpose of ReturnJob in IJobFactory Interface for Quartz.Net

被刻印的时光 ゝ 提交于 2020-01-03 07:37:06
问题 I'm using simpleInjector as IOC container bue I dont have a clear view of what's the responsabillity of ReturnJob , I'd like to know how can I proceed? this is the code I have done so far: public class SimpleInjectorJobFactory:IJobFactory { private readonly Container _container; public SimpleInjectorJobFactory() { _container= new Container(); } public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler) { return _container.GetInstance(bundle.JobDetail.JobType) as IJob; } public void

Simple Injector: Different DbContext for selected controllers

二次信任 提交于 2020-01-02 14:29:22
问题 I am trying to separate reads/writes in my MVC application. I am using Simple Injector as Ioc and I have following structure: new Service( new Repository( new UnitOfWork( new DbContext()))) So UnitOfWork registered per web request all the rest Transient . So idea was to create separate read-only controllers and make a registration of DbContext to supply a different connection if controller is read-only. And that could be achievable with improved RegisterWithContext extension BUT it will not

Simple Injector conditional injection

不打扰是莪最后的温柔 提交于 2020-01-02 02:51:28
问题 Lets say I have two Controllers: ControllerA and ControllerB. Both of those controllers accept as parameter IFooInterface. Now I have 2 implementation of IFooInterface, FooA and FooB. I want to inject FooA in ControllerA and FooB in ControllerB. This was easily achieved in Ninject, but I'm moving to Simple Injector due to better performance. So how can I do this in Simple Injector? Please note that ControllerA and ControllerB resides in different assemblies and are loaded dynamically. Thanks

How to get OwinContext from Global.asax?

蓝咒 提交于 2020-01-01 04:07:28
问题 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(() => HttpContext.Current.GetOwinContext().Authentication); But when I am running my application I get this message: No owin.Environment item was found in the context Why is this HttpContext.Current.GetOwinContext() not available from Global.asax? Startup.cs

How to get OwinContext from Global.asax?

怎甘沉沦 提交于 2020-01-01 04:07:07
问题 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(() => HttpContext.Current.GetOwinContext().Authentication); But when I am running my application I get this message: No owin.Environment item was found in the context Why is this HttpContext.Current.GetOwinContext() not available from Global.asax? Startup.cs

How to configure simple injector container and lifestylse in a MVC web app with WebAPI, WCF, SignalR and Background Task

心不动则不痛 提交于 2020-01-01 02:25:11
问题 The simple injector documentation provides great examples on how to setup the container for WebRequest, Web API, WCF, ... but the examples are specific to one technology/lifestyle at a time. Our web application uses most of them together! It is not clear to me how to configure the container to work with several lifestyles. Let's say I have a MVC project with Web API. I have the following objects: MyDbContext : My entity code first db context IMyDataProvider implemented by MyDataProvider :

Get the container instance for Simple Injector

廉价感情. 提交于 2019-12-31 12:35:14
问题 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 void Initialize() { // Did you know the container can diagnose your configuration? // Go to: https://simpleinjector.org/diagnostics var container = new Container(); //Container configuration code DependencyResolver.SetResolver( new

Unable to register Api Controller using Simple Injector?

﹥>﹥吖頭↗ 提交于 2019-12-31 02:29:06
问题 I have a WebApi that uses Simple Injector that was working perfectly fine, but i had to implement OAuth in to the project. Now i have done that and my ApiControllers give me an error like Simple Injector has now been setup correctly I have my Start.cs file public class Startup { public void Configuration(IAppBuilder app) { // Web API configuration and services HttpConfiguration config = new HttpConfiguration(); Container container = SimpleInjectorConfig.Initialize(app); ConfigureAuth(app,

Simple Injector Diagnostic Warning Disposable Transient

女生的网名这么多〃 提交于 2019-12-30 18:44:08
问题 I am trying to configure simple injector to work, but I can't seem to get pass this. I followed the instructions on how to fix this in this link but it didn't work. Here is the error message: NotificationEntities is registered as transient, but implements IDisposable. Here is the code to the SimpleInjectorInitializer.cs public static void Initialize() { var container = new Container(); container.Options.DefaultScopedLifestyle = new WebRequestLifestyle(); InitializeContainer(container);

Using Simple Injector with SignalR

…衆ロ難τιáo~ 提交于 2019-12-28 04:49:18
问题 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) { container.Register<IMongoHelper<UserDocument>, MongoHelper<UserDocument>>(); // ... registrations like about and then: var resolver = new SimpleInjectorResolver(container); GlobalHost.DependencyResolver = resolver; } and then my class: public class SimpleInjectorResolver :