ioc-container

Simple Injector Property Injection

早过忘川 提交于 2019-12-11 11:57:41
问题 How do you perform property injection with Simple Injector. The with Ninject you do is as per bellow: [Inject] public IUnitOfWork UnitOfWork { get; set; } How can I do the equivalent to this with Simple Injector. I tried finding a solution online but had no luck. Why do I want to use Property Injection? I want to use property injection to set up unit of work in my base controller so that it will create a new unit of work OnActionExecuting and commit the changes OnResultExecuted . It also

IOC Container Runtime Resolution

冷暖自知 提交于 2019-12-11 11:35:24
问题 I'm trying to find an IOC container that will allow me to have mapping data for a field stored in a database and resolve the interface or object that needs resolved via a string value pulled from the database. Most of the examples I have seen are using interfaces hard coded in code, I want the interface that needs to be resolved to be dynamic. This is what I usually see: var taskController = container.Resolve<ITaskController>(); This is what I would like to see: var strTaskController =

Getting Spring IOC to work with the MVP pattern

吃可爱长大的小学妹 提交于 2019-12-11 10:27:33
问题 I'm attempting to use the MVP design pattern with a Swing application in conjunction with Spring IOC. In MVP the View needs to pass itself into the Presenter, and I can't work out how to do this with Spring. public class MainView implements IMainView { private MainPresenter _presenter; public MainView() { _presenter = new MainPresenter(this,new MyService()); //I want something more like this // _presenter = BeanFactory.GetBean(MainPresenter.class); } } This is my config xml (incorrect) <bean

AnnotationConfigApplicationContext.getBean returns a different bean, Spring

青春壹個敷衍的年華 提交于 2019-12-11 10:20:03
问题 I have a problem that I have a ClassA needs RoomService to be injected, and it works fine that I find in ClassA, the roomService's id is the same. While for some reason, I need roomservice to create room instance based on some input param for me, so I use below config to achieve this: @Configuration @EnableAspectJAutoProxy public class Application { private static ApplicationContext ctx = new AnnotationConfigApplicationContext(Application.class); public static ApplicationContext

Windsor IHandlerSelector in RIA Services Visual Studio 2010 Beta2

余生长醉 提交于 2019-12-11 08:34:24
问题 I want to implement multi tenancy using Windsor and i don't know how to handle this situation: i succesfully used this technique in plain ASP.NET MVC projects and thought incorporating in a RIA Services project would be similar. So i used IHandlerSelector, registered some components and wrote an ASP.NET MVC view to verify it works in a plain ASP.NET MVC environment. And it did! Next step was to create a DomainService which got an IRepository injected in the constructor. This service is hosted

UnityContainer.BuildUp() - Can I make it inject new instances into properties only if these are null?

戏子无情 提交于 2019-12-11 07:44:20
问题 I'm deserializing a class like this one class AClass{ [Dependency] AnotherClass Property{ get; set; } } When I then BuildUp() the object I'd like Unity to create a new instance of AnotherClass only if the property is null and otherwise just perform a BuildUp on it. Is there a simple way to achieve this? Edit: I'm doing mvvm with wpf. The classes are view-models, I serialize them as there are some properties I want to preserve between runs and they also have some dependencies I want unity to

Creating object “Catalog” for DI agnostic library

安稳与你 提交于 2019-12-11 07:09:04
问题 I am developing an internal library that is to be used by other developers in the company that I'm working for. I am applying SOLID patterns and following the best practices as described in Dependency Inject (DI) “friendly” library. My end users would be developers of different applications. Some of them are complex legacy applications with no DI, and others are newer apps that have DI and TDD. Now, I am trying to figure out how to call this DI friendly library from a legacy ASP.NET Webforms

Unity ResolveAll Generics Interface

萝らか妹 提交于 2019-12-11 06:07:27
问题 I'm using Unity IoC, I'd like to register mapping of non generic class to generic interface. After that I'd like to use ResolveAll method for retrieve all registration associated to generic interface. This is the sample code: interface ISample<out T> { } class Ca : ISample<int> { } class Cb : ISample<string> { } class Program { static void Main(string[] args) { var container = new UnityContainer(); container.RegisterType<ISample<int>,Ca>(); container.RegisterType<ISample<string>, Cb>(); var

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