I have a soap web service in my web layer (s#arp architecture) which uses a service like this:
public ReportWebService(IReportService ReportService)
{
Check.Require(ReportService != null, "ReportService may not be null");
this.ReportService = ReportService开发者_Go百科;
}
Can someone please remind me how/where I configure the injection of the implementation for IReportService again?
Thanks.
Christian
The short answer is: Just put ReportService into yourProject.ApplicationServices and it will be injected.
The long answer is: In yourProject.Web in Global.asax you will find the method InitializeServiceLocator(). This calls the static method AddComponents on ComponentRegistrar.
ComponentRegistrar is located in yourProject.web/CastleWindsor. In there you will find
public static void AddComponentsTo(IWindsorContainer container)
{
AddGenericRepositoriesTo(container);
AddCustomRepositoriesTo(container);
AddApplicationServicesTo(container);
container.AddComponent("validator",
typeof(IValidator), typeof(Validator));
}
If you look at AddApplicationServicesTo you can see that is registers all types in yourProject.ApplicationServices (.WithService.FirstInterface()):
private static void AddApplicationServicesTo(IWindsorContainer container)
{
container.Register(
AllTypes.Pick()
.FromAssemblyNamed("NewittsStore.ApplicationServices")
.WithService.FirstInterface());
}
Here is from ComponentRegistrar.cs:
/// <summary>
/// The add application services to.
/// </summary>
/// <param name="container">
/// The container.
/// </param>
private static void AddApplicationServicesTo(IWindsorContainer container)
{
container.Register(AllTypes.Pick().FromAssemblyNamed("MyAssembly.ApplicationServices").WithService.FirstInterface());
}
and here is from the a service
private readonly IDocumentManagementService _client;
public DocumentService(IDocumentManagementService client)
{
_client = client;
}
This should help you out.
精彩评论