Exemplo n.º 1
0
        private static ChannelCreator CreateChannelCreator(IKernel kernel, ComponentModel model, IWcfClientModel clientModel, out IWcfBurden burden)
        {
            ValidateClientModel(clientModel, model);

            var createChannelDelegate = createChannelCache.GetOrAdd(clientModel.GetType(), clientModelType =>
            {
                return((CreateChannelDelegate)Delegate.CreateDelegate(typeof(CreateChannelDelegate),
                                                                      createChannelMethod.MakeGenericMethod(clientModelType)));
            });

            var channelCreator = createChannelDelegate(kernel, clientModel, model, out burden);

            if (channelCreator == null)
            {
                throw new CommunicationException("Unable to generate the channel creator.  " +
                                                 "Either the endpoint could be be created or it's a bug so please report it.");
            }
            return(channelCreator);
        }