1
// Copyright 2004-2008 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.Facilities
.WcfIntegration
18 using System
.ServiceModel
;
19 using System
.ServiceModel
.Description
;
23 public class WindsorServiceHost
: ServiceHost
25 private readonly IKernel kernel
;
27 public WindsorServiceHost(IKernel kernel
, Type serviceType
, params Uri
[] baseAddresses
)
28 : base(serviceType
, baseAddresses
)
33 protected override void OnOpening()
35 Description
.Behaviors
.Add(new WindsorDependencyInjectionServiceBehavior(kernel
));
36 IHandler
[] serviceBehaviorHandlers
= kernel
.GetHandlers(typeof (IServiceBehavior
));
37 foreach (IHandler handler
in serviceBehaviorHandlers
)
39 Description
.Behaviors
.Add((IServiceBehavior
) handler
.Resolve(CreationContext
.Empty
));
41 IHandler
[] endPointBehaviors
= kernel
.GetHandlers(typeof (IEndpointBehavior
));
42 foreach (IHandler handler
in endPointBehaviors
)
44 foreach (ServiceEndpoint endpoint
in Description
.Endpoints
)
46 endpoint
.Behaviors
.Add((IEndpointBehavior
) handler
.Resolve(CreationContext
.Empty
));