inversion-of-control

How to pass parent/child class as constructor parameter with structuremap?

我与影子孤独终老i 提交于 2019-12-11 16:30:03
问题 Interface: public interface IPricingFactorsRepository { IList<LrfInputRates> GetLeaseRateFactorList( string programCode, string countryCode, string currencyCode, string leaseTerm); } Got below derived/implemented class: public class PricingFactorsRepository : IPricingFactorsRepository { } public class OverridePricingFactorsRepository : PricingFactorsRepository { } Outside, there is such class that accept the interface as constructor parameter: public class PricingHandler { public

Can I make a keyed service for AutoFac based on the type of the Open Generic

流过昼夜 提交于 2019-12-11 13:52:12
问题 I would like to make a keyedService based on the T for my Open Generic ICommandHandler. I would like to register a ConsultatCommandHanlder keyed service when the ICommandHandler has a T that inherits from ConsultantCommand Any idea how to do it? Or if it is even possible? I am new to AutoFac and am struggling. I am presently registering CommandHandler like this: //Register All Command Handlers builder.RegisterAssemblyTypes(assemblies) .As( t => t.GetInterfaces() .Where(a => a.IsClosedTypeOf

Why so many terms to say the same thing? IoC and DIP

偶尔善良 提交于 2019-12-11 13:14:43
问题 IoC = Inversion Of Control DIP = Dependency Inversion Principle (D in S.O.L.I.D.) IoC == DIP ? I think so, is true. The world of building software is already so messy, why so many words to say the same thing? (I know DI (Dependency Injection) and it is different of DIP and IoC ) Update: According to the answers, then we can say that: ( DI ) + ( IoC ) = ( Dependency Inversion Principle ) ? 回答1: Inversion of Control is the generic term. Dependency Injection is a specific type of IoC. See

Is it possible to override parameter values when using Method Injection with Unity?

浪子不回头ぞ 提交于 2019-12-11 12:22:32
问题 It says in the Unity manual... ParameterOverride can be used only for constructors. So why are the parameters of methods left out? Cheers, Ian. 回答1: The reason I left it out, quite honestly, was development & test time, plus the fact that method injection is used much, much less than constructor or property injection. In particular, our test and doc teams were holding on by their fingernails trying to keep up with the stuff I was throwing them as it was. There's no technical reason to leave

Remove coupling for EF DBContext and infrastructure layer

我的梦境 提交于 2019-12-11 12:14:57
问题 I defined my interfaces in infrastructure layer, to use Dependency Injection, but now problem, how can i resolve dependency of DBContext using interface, without adding reference to EF dll, in infrasturcure layer and service layer. 回答1: If you need to hide EF completely from your application, you will need to use the repository pattern, hide EF behind your repositories and generate (or write) POCO entities. If you're more pragmatic, you can use generic repositories with IQueryable support,

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

DI Interception vs. AOP

纵然是瞬间 提交于 2019-12-11 11:56:31
问题 From Unity documentation: Unity interception enables you to effectively capture calls to objects and add additional functionality to the target object. Interception is useful when you want to modify the behavior for individual objects but not the entire class, very much as you would do when using the Decorator pattern. It provides a flexible approach for adding new behaviors to an object at run time. Since the very same DP is used in Aspect Oriented Programming (see here) ...In the .NET

Castle Windsor Cannot find my Service Type

◇◆丶佛笑我妖孽 提交于 2019-12-11 11:29:42
问题 Trying to make use of the Castle Windsor IoC. I have a very simple application. My interfaces exist in Test.Services namespace. I get the following exception when compiling: "The type name Test.Services.IParse, Test.Services could not be located" This is my app.config: <configuration> <configSections> <section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor" /> </configSections> <castle> <components> <component id="HtmlTitleRetriever" type="Test

MVVM - Using entities in ViewModels

给你一囗甜甜゛ 提交于 2019-12-11 10:56:10
问题 I am really just starting out with MVVM, IoC and Dependency Injection and I've hit a stumbling block that I don't know how to solve but I do understand why it's happening. I am using Castle Windsor for DI and IoC functionality and MVVM Light as my MVVM framework in a WPF application. Using this tutorial I have managed to get Castle Windsor to create a MainPageViewModel that has a IGroupRepository injected into the constructor. I have registered a mock implementation of this in Castle Windsor.

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