private IInterceptor[] GetInterceptors(IKernel kernel, ComponentModel model, Type serviceContract, IWcfChannelHolder channelHolder, CreationContext context)
{
var interceptors = ObtainInterceptors(kernel, model, context);
// TODO: this should be static and happen in IContributeComponentModelConstruction preferably
var clientModel = (IWcfClientModel)model.ExtendedProperties[WcfConstants.ClientModelKey];
Array.Resize(ref interceptors, interceptors.Length + (clientModel.WantsAsyncCapability ? 2 : 1));
int index = interceptors.Length;
interceptors[--index] = new WcfRemotingInterceptor(clients, channelHolder);
if (clientModel.WantsAsyncCapability)
{
if (channelHolder.RealProxy == null)
{
throw new InvalidOperationException(string.Format(
"Component {0} requested async support, but the channel does not support this capability.", model.Name));
}
var getAsyncType = WcfUtils.SafeInitialize(ref asyncType, () => AsyncType.GetAsyncType(serviceContract));
interceptors[--index] = new WcfRemotingAsyncInterceptor(getAsyncType, clients, channelHolder);
}
return interceptors;
}