simple-injector

Registering DynaCaches with SimpleInjector

六眼飞鱼酱① 提交于 2019-12-11 10:27:11
问题 Hi I am attempting to use Dynacache in my solution to cache data I am returning from Database so when I use Telerik grid to filter the data page etc I dont have to go back to the DB to get the data each time. The example on the DynaCache page shows it being used with Ninject DI as below: kernel.Bind<IDynaCacheService>().To<MemoryCacheService>(); kernel.Bind<ITestClass>().To(Cacheable.CreateType<TestClass>()); I am using SimpleInjector as my DI container. Has anyone used Dynacache with

Dynamically select a concrete object with a name using SimpleInjector

跟風遠走 提交于 2019-12-11 07:29:39
问题 How can I use Simple Injector DI container to register multiple concrete types of IShipper interface and dynamically select them using a name ? If I can't register multiple instances of the same type, is there a different way to do with Simple Injector? public Setup() { var container = new SimpleInjector.Container(); // TODO: Registration required for two different shippers container.Register<UPS, IShipper>(); } public interface IShipper { void Ship(Product product) } public class UPS :

Transient component is registered as transient but implements idisposable

痞子三分冷 提交于 2019-12-11 06:01:44
问题 I use Simple injector but somehow i get error as stated in subject. I tried many things before i decided to post this question for instance this is not working for me. I get the following exception when I call Validate : Validation error message: The configuration is invalid. The following diagnostic warnings were reported: -[Disposable Transient Component] AlbumsController is registered as transient, but implements IDisposable. -[Disposable Transient Component] ArtistsController is

How to return an instance based on its parent using Simple Injector?

徘徊边缘 提交于 2019-12-11 05:56:13
问题 We have been using Windsor Castle as our DI Container but we are looking around for alternatives. Now I got to the Simple Injector and so far I have been impressed by its simplicity but one scenario I am stuck at right now is when we are using late bound instantiation for some of our components. My first question is, is it even possible? With Windsor it is done like this; Container.Register(Component.For<ILogger>() .UsingFactoryMethod( (kernel, componentModel, context) => new Logger( context

Register generic types in SimpleInjector Version 3

a 夏天 提交于 2019-12-11 04:43:14
问题 I've been following the very helpful answer here to organise my unit of work and repositories dynamically using SimpleInjector DI. Using the test service below: public class TestService { public TestService(IRepository<Call> calls){} } In the controller: public class TestingController : Controller { private readonly IUnitOfWork _unitOfWork ; public TestingController(IUnitOfWork unitOfWork, TestService testService) { _unitOfWork = unitOfWork; } } And the bootstrapper: public static class

Simple Injector fails if using verify before setting dependency resolver for MVC 4

我们两清 提交于 2019-12-11 03:15:53
问题 We have an ASP.NET MVC 4 based application that's a couple of years old, and I'm working on ridding it of some technical debt. One of the things I'm doing is introduce dependency injection, so that we can better separate the business logic from the data access implementation, and make it less painful to write isolated unit tests. I've gone with Simple Injector, but I'm having some issues. I've followed the MVC integration guide in the Simple Injector documentation. It describes the

Simple Injector Prevent Locked Container

一曲冷凌霜 提交于 2019-12-11 03:14:45
问题 I need to know if there is a way to prevent the container from locking after calling GetInstance ? I have an implementation INamedInstanceFactory<T> where T : Xamarin.Forms.Page, and I need to have an association between a string and a specific concrete type. Unfortunately in order to make it work I have to resolve INamedInstanceFactory<Page> before all registrations are complete. How can I prevent the container from being locked? Edit: We start with an extension like: public static void

Is there a way to explicitly register open generic decorators with castle windsor

扶醉桌前 提交于 2019-12-11 03:13:39
问题 I use castle windsor a lot in a project i'm working on and use decorators a little so I might have something like this in my installer Component.For<IMyViewModelService>().ImplementedBy<MyViewModelServiceCacheDecorator>().LifestyleTransient() Component.For<IMyViewModelService>().ImplementedBy<MyViewModelService>().LifestyleTransient() So doing this is easy enough and works well. I started reading around the simple injector framework and I really like they way you can specifically set the

Where to put my IoC Container configuration in Service Fabric Service?

拥有回忆 提交于 2019-12-11 02:45:39
问题 I was thinking in placing the IoC Container dependencies configuration under RunAsync method in the Service class but I have a bad feeling that's not the right place to go.. Is there any convention in Azure Service Fabric Services to place this type of configurations without causing any sort of conflicts? Also, where would you place the dispose call? Note: I'm using Simple Injector for this but other examples from other IoC containers should do too. 回答1: You can create your IoC container in

StructureMap and Nested Generics

寵の児 提交于 2019-12-11 01:48:28
问题 I am wondering if there is a way to wire up nested generics within StructureMap without having to specify the internal type or create type specific interfaces. I realize that this is a bit confusing, so a coding example might be a better explanation of the functionality that I am looking for. public interface IParser<T> { } public class Range<T> where T : struct { } public class RangeParser<T> : IParser<Range<T>> { } Theoretically, I would like to be able to follow StructureMap's open generic