.net - Castle Windsor: Registering Generic Classes with a Non-Generic Interface -
I have a class multiple dependencies that is: and relevant castle registrations look like this: However, I have a real problem in solving an example of All of these are successful: However, when I try: The palace complains: Castle.MicroKernel.Handlers.HandlerException: The component can not create 'ApplicationServices.ThirdPartyData.ThirdPartyDataSearchCoordinator Services: - iThirdPartyIntemplate repository 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 I do not want to make the interface normal, so I will not be able to hold a collection of different I You can tell clearly to get started, for example, a
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; }}
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; ();
ishardPortDetta SearchCoderator
.
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; ()
ServiceLocator.Current.GetInstance & lt; IThirdPartyDataSearchCoordinator & gt; ()
3 'As it is to have the dependency to be satisfied. ApplicationServices.ThirdPartyData.ThirdPartyDataSearchCoordinator <3> Waiting for the following dependencies:
1 who was not registered - IUpdater
2 who are not registered what is the ThirdPartyDataSearchCoordinator & LT; TItem, TSearchCriteria, TResult & gt;
that I intend to use against interface in the IThirdPartyDataSearchCoordinator
application. IThirdPartyDataSearchCoordinator
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
Post a Comment