protected override ChannelCreator GetChannel(RestClientModel clientModel, Type contract, Binding binding, string address, IChannelBuilderScope scope) { var remoteAddress = new Uri(address, UriKind.Absolute); if (binding == null) { return(CreateChannelCreator(contract, clientModel, scope, remoteAddress)); } return(CreateChannelCreator(contract, clientModel, scope, binding, remoteAddress)); }
internal object DiscoverChannel(DiscoveredEndpointModel model, IChannelBuilderScope scope) { var discovered = PerformEndpointSearch(scope.Contract, model); if (discovered == null || discovered.Endpoints.Count == 0) { throw new EndpointNotFoundException(string.Format( "Unable to discover the endpoint for contract {0}. " + "Either no service exists or it does not support discovery.", scope.Contract.FullName)); } var binding = model.Binding; var endpointMetadata = discovered.Endpoints[0]; if (discovered.Endpoints.Count > 1 && model.EndpointPreference != null) { endpointMetadata = model.EndpointPreference(discovered.Endpoints); if (endpointMetadata == null) { throw new EndpointNotFoundException(string.Format( "More than one endpoint was discovered for contract {0}. " + "However, an endpoint was not selected. This is most likely " + "a bug with the user-defined endpoint preference.", scope.Contract.FullName)); } } if (binding == null && model.DeriveBinding == false) { binding = GetBindingFromMetadata(endpointMetadata); } var address = endpointMetadata.Address; if (model.Identity != null) { address = new EndpointAddress(address.Uri, model.Identity, address.Headers); } binding = GetEffectiveBinding(binding, address.Uri); var channel = scope.GetChannel(scope.Contract, binding, address)(); if (channel is IContextChannel) { var metadata = new DiscoveredEndpointMetadata(endpointMetadata); ((IContextChannel)channel).Extensions.Add(metadata); } return(channel); }
internal object DiscoverChannel(DiscoveredEndpointModel model, IChannelBuilderScope scope) { var discovered = PerformEndpointSearch(scope.Contract, model); if (discovered == null || discovered.Endpoints.Count == 0) { throw new EndpointNotFoundException(string.Format( "Unable to discover the endpoint for contract {0}. " + "Either no service exists or it does not support discovery.", scope.Contract.FullName)); } var binding = model.Binding; var endpointMetadata = discovered.Endpoints[0]; if (discovered.Endpoints.Count > 1 && model.EndpointPreference != null) { endpointMetadata = model.EndpointPreference(discovered.Endpoints); if (endpointMetadata == null) { throw new EndpointNotFoundException(string.Format( "More than one endpoint was discovered for contract {0}. " + "However, an endpoint was not selected. This is most likely " + "a bug with the user-defined endpoint preference.", scope.Contract.FullName)); } } if (binding == null && model.DeriveBinding == false) { binding = GetBindingFromMetadata(endpointMetadata); } var address = endpointMetadata.Address; if (model.Identity != null) { address = new EndpointAddress(address.Uri, model.Identity, address.Headers); } binding = GetEffectiveBinding(binding, address.Uri); var channel = scope.GetChannel(scope.Contract, binding, address)(); if (channel is IContextChannel) { var metadata = new DiscoveredEndpointMetadata(endpointMetadata); ((IContextChannel)channel).Extensions.Add(metadata); } return channel; }
protected override ChannelCreator CreateChannelCreator(Type contract, RestClientModel clientModel, IChannelBuilderScope scope, params object[] channelFactoryArgs) { var type = typeof(WebChannelFactory <>).MakeGenericType(new[] { contract }); var channelFactory = ChannelFactoryBuilder.CreateChannelFactory(type, clientModel, channelFactoryArgs); scope.ConfigureChannelFactory(channelFactory); var methodInfo = type.GetMethod("CreateChannel", Type.EmptyTypes); return((ChannelCreator)Delegate.CreateDelegate(typeof(ChannelCreator), channelFactory, methodInfo)); }
protected override ChannelCreator GetChannel(RestClientModel clientModel, Type contract, Binding binding, EndpointAddress address, IChannelBuilderScope scope) { return(GetChannel(clientModel, contract, binding, address.Uri.AbsoluteUri, scope)); }
protected virtual ChannelCreator GetChannel(M clientModel, Type contract, Binding binding, EndpointAddress address, IChannelBuilderScope scope) { return(CreateChannelCreator(contract, clientModel, scope, binding, address)); }
protected virtual ChannelCreator GetChannel(M clientModel, Type contract, string configurationName, IChannelBuilderScope scope) { return(CreateChannelCreator(contract, clientModel, scope, configurationName)); }
protected virtual ChannelCreator GetChannel(M clientModel, Type contract, ServiceEndpoint endpoint, IChannelBuilderScope scope) { return(CreateChannelCreator(contract, clientModel, scope, endpoint)); }
protected override ChannelCreator GetChannel(DuplexClientModel clientModel, Type contract, Binding binding, EndpointAddress address, IChannelBuilderScope scope) { return(CreateChannelCreator(contract, clientModel, scope, clientModel.CallbackContext, binding, address)); }
protected override ChannelCreator GetChannel(DuplexClientModel clientModel, Type contract, string configurationName, IChannelBuilderScope scope) { return(CreateChannelCreator(contract, clientModel, scope, clientModel.CallbackContext, configurationName)); }
protected override ChannelCreator GetChannel(DuplexClientModel clientModel, Type contract, ServiceEndpoint endpoint, IChannelBuilderScope scope) { return(CreateChannelCreator(contract, clientModel, scope, clientModel.CallbackContext, endpoint)); }