.net - Castle Windsor: Registering Generic Classes with a Non-Generic Interface -


itemprop = "text">

I have a class multiple dependencies that is:

  public class ThirdPartyDataSearchCoordinator & lt; TItem, TSearchCriteria, TrashTouch & gt; : IThirdPartyDataSearchCoordinator where TItem: class, ITHDRTITIM {public thirdparty data searchordinator (IDataMiner & lt; TSearchCriteria, TResult & gt; [] miners, ITHDTRTTMRipotory & Lt; TITIM & gt; stores, IPAPNIGN Mapper, IUpdater & lt; TItem, TResult & gt; Updater) {this.miners = miners; This.repository = repository; This.mapper = Mapper; this. Updater = updater; }}  

and relevant castle registrations look like this:

  container Kernel Resoler. AdsusbarSolar (New ArraySolver (Container Kernel)); Container.Register (Component.For & lt; IMappingEngine> () example (Mapper.Engine).); Container.AddComponent & LT; IThirdPartyItemRepository & LT; ThirdPartyPackage & gt ;, ThirdPartyPackageRepository & gt; (Typeof (IThirdPartyItemRepository & lt; ThirdPartyPackage & gt; FullName.);); Container. Registration (all types .pick (). Named by the sender (Assembly.GetAssambands (TypditAdministrator)) GateName (.name) .WithService.FirstInterface ()); Container.AddComponent & LT; IThirdPartyDataSearchCoordinator, ThirdPartyDataSearchCoordinator & LT; ThirdPartyPackage, ThirdPartyPackageSearchCriteriaDto, ThirdPartyFlightSearchResultDto & gt; & Gt; ();  

However, I have a real problem in solving an example of ishardPortDetta SearchCoderator .

All of these are successful:

  ServiceLocator.Current.GetInstance & LT; IThirdPartyItemRepository & LT; ThirdPartyPackage & gt; & Gt; () ServiceLocator.Current.GetInstance & LT; IUpdater & LT; ThirdPartyPackage, ThirdPartyPackageSearchResultDto & gt; & Gt; () ServiceLocator.Current.GetInstance & LT; IMappingEngine & gt; () ServiceLocator.Current.GetInstance & LT; IDataMiner & lt; ThirdPartyPackageSearchCriteriaDotto, ThirdPartPackageSearchRetailDraw & gt; & Gt; ()  

However, when I try:

  ServiceLocator.Current.GetInstance & lt; IThirdPartyDataSearchCoordinator & gt; ()  

The palace complains:

Castle.MicroKernel.Handlers.HandlerException: The component can not create 'ApplicationServices.ThirdPartyData.ThirdPartyDataSearchCoordinator 3 'As it is to have the dependency to be satisfied. ApplicationServices.ThirdPartyData.ThirdPartyDataSearchCoordinator <3> Waiting for the following dependencies:

Services: - iThirdPartyIntemplate repository 1 who was not registered - IUpdater 2 who are not registered

Key (component with a specific key) - Miners who were not registered.

Am I forgetting something - or do I expect a lot of castles to solve generic dependence? Way

Edit What do I want to do is clearly register each solid what is the ThirdPartyDataSearchCoordinator & LT; TItem, TSearchCriteria, TResult & gt; that I intend to use against interface in the IThirdPartyDataSearchCoordinator application.

I do not want to make the interface normal, so I will not be able to hold a collection of different IThirdPartyDataSearchCoordinator

I You can tell clearly to get started, for example, a ThirdPartyDataSearchCoordinator. & Lt; ThirdPartyPackage, ThirdPartyPackageSearchCriteriaDto, ThirdPartyPackageSearchResultDto & gt; , without having to feed in all dependencies manually without the constructor?

100% is not fixed, but I think you have to register the open generic interface first . Then You can override a specific implementation.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -