simple-injector

Dependency Injection (using SimpleInjector) and OAuthAuthorizationServerProvider

≯℡__Kan透↙ 提交于 2019-12-18 02:15:35
问题 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 this i started to follow this tutorial, which is very helpful, but doesnt use Dependancy Injection http://bitoftech.net/2014/06/01/token-based-authentication-asp-net-web-api-2-owin-asp-net-identity/ I have my global.asax file looking like this, to

Pass runtime value to constructor using Simple Injector abd WebFormsMVP

删除回忆录丶 提交于 2019-12-17 20:13:18
问题 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:

How to do open generic decorator chaining with unity + UnityAutoRegistration

杀马特。学长 韩版系。学妹 提交于 2019-12-17 19:37:12
问题 Went off on an interesting tangent today after reading this article on command handler decoration. I wanted to see if I could implement the pattern using Unity instead of SimpleInjector, and so far it is proving extremely difficult. The first thing I had to do was install UnityAutoRegistration to resolve the open generic ICommandHandler<TCommand> interface. Current solution for that aspect is as follows: Container = new UnityContainer().LoadConfiguration(); Container.ConfigureAutoRegistration

log4net with DI Simple Injector

戏子无情 提交于 2019-12-17 15:51:57
问题 I am trying to use Simple Injector ( + integration MVC) v 2.5.2. for an MVC 4 Application and I need to track/log performance (execution) as well(by log4net module). Current implementation (during runtime) creates log4net file in specified path but did not write any line of text into it (when I debug it everything went with no error to the end of _logger.Info("message") ). Does anyone try to use Simple Injector DI for log4net? The way how I've registered log4net module is: public static class

How to register Windows Forms with Simple Injector

筅森魡賤 提交于 2019-12-17 07:39:20
问题 Background I'm building a winforms application where I am using an IoC container (SimpleInjector) to register my types. In my application, a majority of the screens (i.e. forms) will only have one instance at any given time. Problem For forms that only need one instance at any given time, I can register them as singletons: container.Register<IHomeView, HomeView>(Lifestyle.Singleton); This allows me to use the container to keep track of all forms. In this case, however, when a form gets closed

Dependency Injection to resolve dependency with runtime data

坚强是说给别人听的谎言 提交于 2019-12-14 03:58:34
问题 I am using simple injector for my web api project. I have a service which requires a session token in order for it to instantiate. public class CustomerService { public CustomerService(Auth auth, IRepositoryFactory repositoryFactory) { // make post call to another web api for validation SomeWebApiCallToValidateAuth.vaildate(auth); } } So for this service, it requires an auth token and a repositoryFactory. I want it to be able to inject the auth parameter (which comes from the http web request

Dependency Scope Issues with MediatR and SimpleInjector

一笑奈何 提交于 2019-12-13 14:12:25
问题 I've been experimenting with the mediator pattern and CQRS using the MediatR library in a WinForms application that uses the Entity Framework for data access. The application is used in a batch manufacturing plant, and allows users to see a list of active and completed batches, and if necessary make updates to batch information. Each batch has a large amount of information associated with it, such as quality and process measurements. Reading and writing data is organized into Queries and

How to use Simple injector, Repository and Context - code first

我们两清 提交于 2019-12-13 11:33:17
问题 I'm trying to use Simple Injector to create my repository and use it in the Business logic layer ( also i want to use PerWebRequest method ) . In the DAL layer i have : public interface IRepository<T> where T : class { void Add(T entity); void Delete(T entity); void Delete(int id); void Update(T entity); T GetById(int Id); IQueryable<T> All(); IEnumerable<T> Find(Func<T, bool> predicate); } and : public class EFRepository<T> : IRepository<T>, IDisposable where T : class { #region Members

Implement Simple Injector with generic repository

淺唱寂寞╮ 提交于 2019-12-13 07:45:42
问题 I have some problem to implement SimpleInjector with my generic Repository. I have an interface IRepository<T> where T : class and an abstract class abstract class Repository<C, T> : IRepository<T> where T : class where C : DbContext which implements the interface. Finally I have my entity repositories which inherit the abstract class. Here's a concret example: public interface IRepository<T> where T : class { IQueryable<T> GetAll(); IQueryable<T> FindBy(Expression<Func<T, bool>> predicate);

Simple Injector: How can I skip verification of an object in the container

一笑奈何 提交于 2019-12-13 02:48:45
问题 I'm using Simple Injector to inject dependencies into my objects via Constructor Injection. For a particular set of objects (all derived from a common abstract base class) I inject a factory instead of the concrete object so that I can determine at run-time which derived instance should be injected. The factory is registered with the container as a singleton, as are the derived instances. After registering all of my objects with the DI Container I call the Container.Verify() method to verify