/// <summary> /// Gets an instance of a class that inherits from the <see cref="Binding"/> class. /// </summary> /// <param name="serviceType">The service type for which to return a <see cref="Binding"/></param> /// <returns>An instance of a class that inherits from the <see cref="Binding"/> class.</returns> public virtual Binding GetBinding(Type serviceType) { Uri uri = uriProvider.GetUri(serviceType); Binding binding; switch (uri.Scheme) { case "net.tcp": binding = new NetTcpBinding(SecurityMode.None); break; case "http": binding = new BasicHttpBinding(); break; case "https": binding = new WSHttpBinding(SecurityMode.None); break; case "net.pipe": binding = new NetNamedPipeBinding(); break; default: throw new InvalidOperationException(string.Format("Unable to resolve binding for Uri: {0}", uri)); } return(binding); }
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { var link = value as Link; if (link == null) { writer.WriteNull(); return; } var uri = _uriProvider.GetUri(link.Uri, link.Location); writer.WriteValue(uri); }
/// <summary> /// Gets a <see cref="ChannelFactory{TChannel}"/> that is used to /// create a <typeparamref name="TService"/> channel. /// </summary> /// <typeparam name="TService">The service type for which to get a <see cref="ChannelFactory{TChannel}"/>.</typeparam> /// <returns>a <see cref="ChannelFactory{TChannel}"/> that is used to create a <typeparamref name="TService"/> channel.</returns> public virtual ChannelFactory <TService> GetChannelFactory <TService>() { var binding = bindingProvider.GetBinding(typeof(TService)); var uri = uriProvider.GetUri(typeof(TService)); var channelFactory = new ChannelFactory <TService>(binding, new EndpointAddress(uri)); foreach (var endpointBehavior in endpointBehaviors) { channelFactory.Endpoint.EndpointBehaviors.Add(endpointBehavior); } return(channelFactory); }