The facility allows scopes to be associated with a behavior.  If you wanted to 
apply it to a specific service, you would add the behavior with the explicit 
scope.

e.g.
        using (container.AddFacility<WcfFacility>(f => f.CloseTimeout = 
TimeSpan.Zero)
                                .Register(
                                        Component.For<ErrorLogger>()
                                                
.Attribute("scope").Eq(WcfExtensionScope.Explicit),
                                        
Component.For<IOperationsEx>().ImplementedBy<Operations>()
                                                .DependsOn(new { number = 42 })
                                                .AsWcfService(new 
DefaultServiceModel().AddEndpoints(
                                                        WcfEndpoint.BoundTo(new 
NetTcpBinding { PortSharingEnabled = true })
                                                                
.At("net.tcp://localhost/Operations"))
                                                                
.AddExtensions(typeof(ErrorLogger))
                                                )
                                ))

This fragment was taken from the ServiceHostFixture in the source code and 
shows you how to mark a behavior explicit and
then explicitly add it to a service.

On Jan 25, 2011, at 11:37 AM, Jesse wrote:

> Craig, this work as expected. Thank you very much for your insight.
> 
> One last question, how do I apply the IContractBehavior to apply to a
> service through the container and not all wcf services?
> 
> Thanks again,
> Jesse
> 
> On Jan 21, 9:28 am, Craig Neuwirt <[email protected]> wrote:
>> Jesse,
>> 
>>   You just need to create an IContractBehavior (probably implementing 
>> IErrorHandler too) and add the FaultDescriptions there.
>> You can then just add the behavior to the container and it will attach it 
>> automatically.
>> 
>> On Jan 21, 2011, at 11:12 AM, Jesse wrote:
>> 
>>> Thanks for the feedback Craig, I was thinking that might be the
>>> problem. Maybe I am going the wrong direction then, my main reason for
>>> creating a custom host is to add a fault to every operation by
>>> overriding CreateDescription of DefaultServiceHost.
>>> Here is the sample code
>> 
>>>                               protected override ServiceDescription
>>> CreateDescription(out IDictionary<string, ContractDescription>
>>> implementedContracts) {
>> 
>>>                    var serviceDescription = base.CreateDescription(out
>>> implementedContracts);
>> 
>>>                    Type validationFaultType = typeof(ValidationFault);
>> 
>>>                    foreach (var endpoint in serviceDescription.Endpoints) {
>>>                            foreach (var operation in 
>>> endpoint.Contract.Operations) {
>> 
>>>                                    var validationFaultDescription = new
>>> FaultDescription(operation.Name){
>>>                                            Name = validationFaultType.Name,
>>>                                            Namespace = 
>>> validationFaultType.Namespace,
>>>                                            DetailType = validationFaultType
>>>                                    };
>>>                                    
>>> operation.Faults.Add(validationFaultDescription);
>>>                            }
>>>                    }
>> 
>>>                    return serviceDescription;
>>>            }
>> 
>>> Do you have thoughts for another implementation that will not require
>>> me to create my own host, or should I just create an implemenataion of
>>> IWcfServiceModel and use my own ServiceHostBuilder?
>> 
>>> Thank you very much for you insight.
>> 
>>> Jesse
>> 
>>> On Jan 21, 4:36 am, Craig Neuwirt <[email protected]> wrote:
>>>> Usually, a new ServiceHostBuilder uses a corresponding IWcfServiceModel.  
>>>> It seams that in your example, you are adding another builder for the 
>>>> DefaultServiceModel.  Since one already exists, that is the one being used.
>> 
>>>> On Jan 20, 2011, at 7:10 PM, Jesse wrote:
>> 
>>>>> I need to create a custom ServiceHost but still keep benefitting from
>>>>> the WCF Facility. My ServiceHost extends DefaultServiceHost and  I
>>>>> thought I could create this by implemenentingIServiceHostBuilder. I
>>>>> register the service host builder like so
>> 
>>>>> Component.For<IServiceHostBuilder<DefaultServiceModel>>().ImplementedBy<Ret
>>>>>  ailServiceHostBuilder>(),
>> 
>>>>> but my customIServiceHostBuildernever gets called and the
>>>>> DefaultServiceHostBuilder from the WCF Facility still is the one
>>>>> creating the Host. How can I get my customIServiceHostBuilderto run?
>>>>> Or is there a better way to create my own ServiceHost?
>> 
>>>>> Thanks,
>>>>> Jesse
>> 
>>>>> --
>>>>> You received this message because you are subscribed to the Google Groups 
>>>>> "Castle Project Users" group.
>>>>> To post to this group, send email to 
>>>>> [email protected].
>>>>> To unsubscribe from this group, send email to 
>>>>> [email protected].
>>>>> For more options, visit this group 
>>>>> athttp://groups.google.com/group/castle-project-users?hl=en.-Hide quoted 
>>>>> text -
>> 
>>>> - Show quoted text -
>> 
>>> --
>>> You received this message because you are subscribed to the Google Groups 
>>> "Castle Project Users" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to 
>>> [email protected].
>>> For more options, visit this group 
>>> athttp://groups.google.com/group/castle-project-users?hl=en.
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Castle Project Users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/castle-project-users?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en.

Reply via email to