inversion-of-control

Cannot get Ninject.Extensions.Conventions to work

时间秒杀一切 提交于 2019-12-31 02:01:09
问题 I've been trying to get Ninject.Extensions.Conventions for (Ninject 3+) working, with no luck. I boiled it down to a found sample console app, and I can't even get that going. Here's what I have: class Program { static void Main(string[] args) { var kernel = new StandardKernel(); kernel.Bind(x => x .FromThisAssembly() .SelectAllClasses() .BindAllInterfaces()); var output = kernel.Get<IConsoleOutput>(); output.HelloWorld(); var service = kernel.Get<Service>(); service.OutputToConsole();

Castle Windsor IoC Property Injection simple how-to

自古美人都是妖i 提交于 2019-12-30 18:38:07
问题 OK I think there is maybe too much information about Castle Windsor because looking for these keywords gives me examples of everything, and frankly I don't understand enough about how it works to properly troubleshoot this. I have tried quite a few permutations with little luck at this point. I have an IUnitOfWorkFactory that I want to instantiate as a singleton. So, I install Castle Windsor, write a bit of code like so: iocContainer = new WindsorContainer() .Install(FromAssembly.This()); var

MEF & separate Interface assembly leads to “Interface for every class”

末鹿安然 提交于 2019-12-30 18:27:40
问题 I'm getting my feet wet with DI/IoC and MEF in particular. I have a web application that has two types of parts (maybe more someday) defined by interfaces which need access to the whole environment. The application has a list with concrete implementations for each type, composed by MEF. The environment consists of: several repositories current application request render engine navigation engine plus some static utility classes How can I put the Interface definitions in a seperate assembly and

MEF & separate Interface assembly leads to “Interface for every class”

社会主义新天地 提交于 2019-12-30 18:26:13
问题 I'm getting my feet wet with DI/IoC and MEF in particular. I have a web application that has two types of parts (maybe more someday) defined by interfaces which need access to the whole environment. The application has a list with concrete implementations for each type, composed by MEF. The environment consists of: several repositories current application request render engine navigation engine plus some static utility classes How can I put the Interface definitions in a seperate assembly and

How does Castle Windsor respond to a class which implements multiple interfaces?

柔情痞子 提交于 2019-12-30 09:40:51
问题 For example I have two interfaces: ICustomerService and IOrderService which each has a couple of functions like GetCustomer, GetOrder, etc. I want one class to implement both interfaces: Server. How does Castle Windsor respond to this? Is it possible in the first place? When I resolve the Server object based on one of the two interfaces, will I get the same object? What happens when I have a constructor that has both interfaces in its parameters? Will there still be one object constructed.

Resolving named dependencies with Unity

筅森魡賤 提交于 2019-12-30 08:34:50
问题 I have a service with 2 dependencies: a Repository and a Gateway (sms). I need to resolve 2 different versions of the service that only differ on one of the parameters passed to the gateway. The code is simplified to as follows public interface IService { string DoSomething(); } public interface IServiceFoo { string DoSomething(); } public interface IServiceBar { string DoSomething(); } public interface IRepository { } public class Repository : IRepository { } public interface IGateway {

What DI/IoC framework should I learn next? [closed]

怎甘沉沦 提交于 2019-12-30 07:33:07
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . I've used Spring and Spring.NET quite a bit, but I would like to see what else is out there. Can anyone recommend a good Java or .NET framework that I could try to learn? 回答1: Here is a list of IoC containers from the good Mr. Hanselman... 回答2: Castle Windsor is very popular,

What DI/IoC framework should I learn next? [closed]

不羁岁月 提交于 2019-12-30 07:32:02
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . I've used Spring and Spring.NET quite a bit, but I would like to see what else is out there. Can anyone recommend a good Java or .NET framework that I could try to learn? 回答1: Here is a list of IoC containers from the good Mr. Hanselman... 回答2: Castle Windsor is very popular,

DI and Singleton Pattern in one implementation

风格不统一 提交于 2019-12-30 03:30:19
问题 I want to refactor some code using the Windsor IOC/DI framework, but my issue is that I have some Singleton classes and Factory pattern classes and I am not sure that one can implement a Singleton or Factory using DI. Has anyone any ideas if that is possible and how? 回答1: The Singleton design pattern is at odds with DI. While it's possible to open up a Singleton so much that DI and the Open/Closed Principle starts to make sense, this will change the Singleton so much that it almost stops

Inversion of Control with .net

扶醉桌前 提交于 2019-12-30 03:24:05
问题 It's rare that I hear someone using Inversion of Control (Ioc) principle with .Net. I have some friends that work with Java that use a lot more Ioc with Spring and PicoContainer. I understand the principle of removing dependencies from your code... but I have a doubt that it's so much better. Why do .Net programmers not use (or use less) those types of frameworks? If you do, do you really find a positive effect in the long term? 回答1: Lots of people use IOC in .NET, and there are several