/// <summary> /// Creates the <see cref="Uri"/> for this endpoint. /// </summary> /// <param name="scheme">The Uri scheme.</param> /// <param name="meta">The hosted service metadata.</param> /// <returns>An instance of <see cref="Uri"/>.</returns> protected virtual Uri CreateUri(string scheme, IHostedServiceMetadata meta) { //string IP4v = "localhost"; string IP4v = CommonUtility.GetHostIP4v(); var builder = new UriBuilder(scheme, IP4v, Port, Path ?? meta.Name); return builder.Uri; }
/// <summary> /// Creates an instance of a <see cref="ServiceEndpoint"/> that represents the endpoint. /// </summary> /// <param name="description">The contract description.</param> /// <param name="meta">The hosted service metadata.</param> /// <returns>An instance of <see cref="ServiceEndpoint"/></returns> internal override ServiceEndpoint CreateEndpoint(ContractDescription description, IHostedServiceMetadata meta) { var uri = CreateUri("net.tcp", meta); var address = new EndpointAddress(uri); var binding = new NetTcpBinding(); return new ServiceEndpoint(description, binding, address); }
/// <summary> /// Creates the <see cref="Uri"/> for this endpoint. /// </summary> /// <param name="scheme">The Uri scheme.</param> /// <param name="meta">The hosted service metadata.</param> /// <returns>An instance of <see cref="Uri"/>.</returns> protected virtual Uri CreateUri(string scheme, IHostedServiceMetadata meta) { //string IP4v = "localhost"; string IP4v = CommonUtility.GetHostIP4v(); var builder = new UriBuilder(scheme, IP4v, Port, Path ?? meta.Name); return(builder.Uri); }
/// <summary> /// Creates an instance of a <see cref="ServiceEndpoint"/> that represents the endpoint. /// </summary> /// <param name="description">The contract description.</param> /// <param name="meta">The hosted service metadata.</param> /// <returns>An instance of <see cref="ServiceEndpoint"/></returns> internal override ServiceEndpoint CreateEndpoint(ContractDescription description, IHostedServiceMetadata meta) { var uri = CreateUri((UseHttps) ? "https" : "http", meta); var address = new EndpointAddress(uri); var binding = CreateBinding(BindingType); return new ServiceEndpoint(description, binding, address); }
/// <summary> /// Initialises a new instance of <see cref="ExportServiceHost"/>. /// </summary> /// <param name="meta">The service host metadata.</param> /// <param name="baseAddresses">The collection of base addresses</param> public ExportServiceHost(IHostedServiceMetadata meta, Uri[] baseAddresses) { Meta = meta ?? throw new ArgumentNullException("meta"); _baseAddresses = (baseAddresses == null || baseAddresses.Length == 0) ? null : baseAddresses; InitializeDescription(new UriSchemeKeyedCollection(baseAddresses)); }
/// <summary> /// Creates an instance of <see cref="ExportServiceHost"/> using service metadata. /// </summary> /// <param name="container">The composition container.</param> /// <param name="meta">The metadata.</param> public static ExportServiceHost CreateExportServiceHost(CompositionContainer container, IHostedServiceMetadata meta) { if (container == null) throw new ArgumentNullException("container"); if (meta == null) throw new ArgumentNullException("meta"); var host = new ExportServiceHost(meta, new Uri[0]); host.Description.Behaviors.Add(new ExportServiceBehavior(container, meta.Name)); #if WITH_TOKEN if (meta.TokenValidationMode == TokenValidationMode.Check) host.Description.Behaviors.Add(new TokenValidationServiceBehavior(container)); #endif #if WITH_ERROR_HANDLER foreach (ServiceEndpoint se in host.Description.Endpoints) se.Behaviors.Add(new EndpointErrorHandlerBehavior(container)); #endif return host; }
/// <summary> /// Creates an instance of <see cref="ExportServiceHost"/> using service metadata. /// </summary> /// <param name="container">The composition container.</param> /// <param name="meta">The metadata.</param> public static ExportServiceHost CreateExportServiceHost(CompositionContainer container, IHostedServiceMetadata meta) { if (container == null) throw new ArgumentNullException("container"); if (meta == null) throw new ArgumentNullException("meta"); var host = new ExportServiceHost(meta, new Uri[0]); host.Description.Behaviors.Add(new ExportServiceBehavior(container, meta.Name)); foreach (var behavior in BehaviorFactory.GetConfiguredBehaviors(meta.Name)) { var behaviorType = behavior.GetType(); if (host.Description.Behaviors.Contains(behaviorType)) { host.Description.Behaviors.Remove(behaviorType); } host.Description.Behaviors.Add(behavior); } return host; }
/// <summary> /// Creates an instance of <see cref="ExportServiceHost"/> using service metadata. /// </summary> /// <param name="container">The composition container.</param> /// <param name="meta">The metadata.</param> public static ExportServiceHost CreateExportServiceHost(CompositionContainer container, IHostedServiceMetadata meta) { if (container == null) { throw new ArgumentNullException("container"); } if (meta == null) { throw new ArgumentNullException("meta"); } var host = new ExportServiceHost(meta, new Uri[0]); host.Description.Behaviors.Add(new ExportServiceBehavior(container, meta.Name)); foreach (var behavior in BehaviorFactory.GetConfiguredBehaviors(meta.Name)) { var behaviorType = behavior.GetType(); if (host.Description.Behaviors.Contains(behaviorType)) { host.Description.Behaviors.Remove(behaviorType); } host.Description.Behaviors.Add(behavior); } return(host); }
/// <summary> /// Creates an instance of a <see cref="ServiceEndpoint"/> that represents the endpoint. /// </summary> /// <param name="description">The contract description.</param> /// <param name="meta">The hosted service metadata.</param> /// <returns>An instance of <see cref="ServiceEndpoint"/></returns> internal abstract ServiceEndpoint CreateEndpoint(ContractDescription description, IHostedServiceMetadata meta);
/// <summary> /// Creates an instance of a <see cref="ServiceEndpoint"/> that represents the endpoint. /// </summary> /// <param name="description">The contract description.</param> /// <param name="meta">The hosted service metadata.</param> /// <returns>An instance of <see cref="ServiceEndpoint"/></returns> internal override ServiceEndpoint CreateEndpoint(ContractDescription description, IHostedServiceMetadata meta) { var uri = CreateUri(Uri.UriSchemeNetTcp, meta); var address = new EndpointAddress(uri); var binding = (BindingConfiguration == null) ? new NetTcpBinding() : new NetTcpBinding(BindingConfiguration); binding.ReliableSession.Enabled = this.ReliableSession; return(new ServiceEndpoint(description, binding, address)); }
/// <summary> /// Creates the <see cref="Uri"/> for this endpoint. /// </summary> /// <param name="scheme">The Uri scheme.</param> /// <param name="meta">The hosted service metadata.</param> /// <returns>An instance of <see cref="Uri"/>.</returns> protected virtual Uri CreateUri(string scheme, IHostedServiceMetadata meta) { var builder = new UriBuilder(scheme, "localhost", this.Port, this.Path ?? meta.Name); return(builder.Uri); }
/// <summary> /// Gets the service endpoints for the service. /// </summary> /// <param name="attributes">The set of endpoint attributes.</param> /// <param name="meta">The service metadata.</param> /// <param name="description">The contract description</param> /// <returns>The set of endpoints.</returns> private static IEnumerable <ServiceEndpoint> GetServiceEndpoints(IEnumerable <EndpointAttribute> attributes, IHostedServiceMetadata meta, ContractDescription description) { return(attributes.Select(a => a.CreateEndpoint(description, meta))); }
/// <summary> /// Creates an instance of a <see cref="ServiceEndpoint"/> that represents the endpoint. /// </summary> /// <param name="description">The contract description.</param> /// <param name="meta">The hosted service metadata.</param> /// <returns>An instance of <see cref="ServiceEndpoint"/></returns> internal override ServiceEndpoint CreateEndpoint(ContractDescription description, IHostedServiceMetadata meta) { var uri = CreateUri(Uri.UriSchemeNetPipe, meta); var address = new EndpointAddress(uri); var binding = (BindingConfiguration == null) ? new NetNamedPipeBinding() : new NetNamedPipeBinding(BindingConfiguration); return(new ServiceEndpoint(description, binding, address)); }
/// <summary> /// Creates an instance of a <see cref="ServiceEndpoint"/> that represents the endpoint. /// </summary> /// <param name="description">The contract description.</param> /// <param name="meta">The hosted service metadata.</param> /// <returns>An instance of <see cref="ServiceEndpoint"/></returns> internal override ServiceEndpoint CreateEndpoint(ContractDescription description, IHostedServiceMetadata meta) { var uri = CreateUri("net.tcp", meta); var address = new EndpointAddress(uri); var binding = new NetTcpBinding(); binding.PortSharingEnabled = true; #if WindowsSecurityMode binding.Security.Mode = SecurityMode.Transport; binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows; #else binding.Security.Mode = SecurityMode.None; binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None; #endif return(new ServiceEndpoint(description, binding, address)); }
/// <summary> /// Creates an instance of <see cref="ExportServiceHost"/> using service metadata. /// </summary> /// <param name="container">The composition container.</param> /// <param name="meta">The metadata.</param> public static ExportServiceHost <T> CreateExportServiceHost(CompositionContainer container, IHostedServiceMetadata meta) { if (container == null) { throw new ArgumentNullException("container"); } if (meta == null) { throw new ArgumentNullException("meta"); } var host = new ExportServiceHost <T>(meta, new Uri[0]); host.Description.Behaviors.Add(new ExportServiceBehavior <T>(container, meta.Name)); return(host); }
/// <summary> /// Creates an instance of <see cref="ExportServiceHost"/> using service metadata. /// </summary> /// <param name="container">The composition container.</param> /// <param name="meta">The metadata.</param> public static ExportServiceHost CreateExportServiceHost(CompositionContainer container, IHostedServiceMetadata meta) { if (container == null) { throw new ArgumentNullException("container"); } if (meta == null) { throw new ArgumentNullException("meta"); } var host = new ExportServiceHost(meta, new Uri[0]); host.Description.Behaviors.Add(new ExportServiceBehavior(container, meta.Name)); #if WITH_TOKEN if (meta.TokenValidationMode == TokenValidationMode.Check) { host.Description.Behaviors.Add(new TokenValidationServiceBehavior(container)); } #endif #if WITH_ERROR_HANDLER foreach (ServiceEndpoint se in host.Description.Endpoints) { se.Behaviors.Add(new EndpointErrorHandlerBehavior(container)); } #endif return(host); }
/// <summary> /// Creates an instance of a <see cref="ServiceEndpoint"/> that represents the endpoint. /// </summary> /// <param name="description">The contract description.</param> /// <param name="meta">The hosted service metadata.</param> /// <returns>An instance of <see cref="ServiceEndpoint"/></returns> internal override ServiceEndpoint CreateEndpoint(ContractDescription description, IHostedServiceMetadata meta) { var uri = CreateUri((UseHttps) ? "https" : "http", meta); var address = new EndpointAddress(uri); var binding = CreateBinding(BindingType); return(new ServiceEndpoint(description, binding, address)); }
/// <summary> /// Creates the <see cref="Uri"/> for this endpoint. /// </summary> /// <param name="scheme">The Uri scheme.</param> /// <param name="meta">The hosted service metadata.</param> /// <returns>An instance of <see cref="Uri"/>.</returns> protected virtual Uri CreateUri(string scheme, IHostedServiceMetadata meta) { var builder = new UriBuilder(scheme, "localhost", Port, Path ?? meta.Name); return builder.Uri; }