BindingContext(CustomBinding binding, BindingElementCollection remainingBindingElements, BindingParameterCollection parameters, Uri listenUriBaseAddress, string listenUriRelativeAddress, ListenUriMode listenUriMode) { Initialize(binding, remainingBindingElements, parameters, listenUriBaseAddress, listenUriRelativeAddress, listenUriMode); }
private bool PrepareElements() { if (elements != empty_collection) { return(false); } elements = binding.CreateBindingElements(); return(true); }
private void Initialize(CustomBinding binding, BindingElementCollection remainingBindingElements, BindingParameterCollection parameters, Uri listenUriBaseAddress, string listenUriRelativeAddress, System.ServiceModel.Description.ListenUriMode listenUriMode) { this.binding = binding; this.remainingBindingElements = new BindingElementCollection(remainingBindingElements); this.bindingParameters = new BindingParameterCollection(parameters); this.listenUriBaseAddress = listenUriBaseAddress; this.listenUriRelativeAddress = listenUriRelativeAddress; this.listenUriMode = listenUriMode; }
private void Initialize(CustomBinding binding, BindingElementCollection remainingBindingElements, BindingParameterCollection parameters) { _binding = binding; _remainingBindingElements = new BindingElementCollection(remainingBindingElements); _bindingParameters = new BindingParameterCollection(parameters); }
public BindingElementCollection Clone() { BindingElementCollection elements = new BindingElementCollection(); for (int i = 0; i < base.Count; i++) { elements.Add(base[i].Clone()); } return(elements); }
// returns a new collection with clones of all the elements public BindingElementCollection Clone() { BindingElementCollection result = new BindingElementCollection(); for (int i = 0; i < this.Count; i++) { result.Add(this[i].Clone()); } return(result); }
private XmlElement CreateReliabilityAssertion(PolicyVersion policyVersion, BindingElementCollection bindingElements) { string str; string str2; string str3; string str4; XmlDocument doc = new XmlDocument(); XmlElement childElement = null; if (this.ReliableMessagingVersion == System.ServiceModel.ReliableMessagingVersion.WSReliableMessagingFebruary2005) { str = "wsrm"; str2 = "http://schemas.xmlsoap.org/ws/2005/02/rm/policy"; str3 = str; str4 = str2; } else { str = "wsrmp"; str2 = "http://docs.oasis-open.org/ws-rx/wsrmp/200702"; str3 = "netrmp"; str4 = "http://schemas.microsoft.com/ws-rx/wsrmp/200702"; } XmlElement element2 = doc.CreateElement(str, "RMAssertion", str2); if (this.ReliableMessagingVersion == System.ServiceModel.ReliableMessagingVersion.WSReliableMessaging11) { XmlElement newChild = CreatePolicyElement(policyVersion, doc); if (IsSecureConversationEnabled(bindingElements)) { XmlElement element4 = doc.CreateElement(str, "SequenceSTR", str2); newChild.AppendChild(element4); } XmlElement element5 = doc.CreateElement(str, "DeliveryAssurance", str2); XmlElement element6 = CreatePolicyElement(policyVersion, doc); XmlElement element7 = doc.CreateElement(str, "ExactlyOnce", str2); element6.AppendChild(element7); if (this.ordered) { XmlElement element8 = doc.CreateElement(str, "InOrder", str2); element6.AppendChild(element8); } element5.AppendChild(element6); newChild.AppendChild(element5); element2.AppendChild(newChild); } childElement = doc.CreateElement(str3, "InactivityTimeout", str4); WriteMillisecondsAttribute(childElement, this.InactivityTimeout); element2.AppendChild(childElement); childElement = doc.CreateElement(str3, "AcknowledgementInterval", str4); WriteMillisecondsAttribute(childElement, this.AcknowledgementInterval); element2.AppendChild(childElement); return(element2); }
internal BindingElementCollection(BindingElementCollection elements) { if (elements == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("elements"); } for (int i = 0; i < elements.Count; i++) { base.Add(elements[i]); } }
internal CustomBinding(BindingElementCollection bindingElements) { this.bindingElements = new BindingElementCollection(); if (bindingElements == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("bindingElements"); } for (int i = 0; i < bindingElements.Count; i++) { this.bindingElements.Add(bindingElements[i]); } }
public CustomBinding(IEnumerable <BindingElement> bindingElementsInTopDownChannelStackOrder) { this.bindingElements = new BindingElementCollection(); if (bindingElementsInTopDownChannelStackOrder == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("bindingElements"); } foreach (BindingElement element in bindingElementsInTopDownChannelStackOrder) { this.bindingElements.Add(element); } }
public CustomBinding(string name, string ns, params BindingElement[] bindingElementsInTopDownChannelStackOrder) : base(name, ns) { this.bindingElements = new BindingElementCollection(); if (bindingElementsInTopDownChannelStackOrder == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("bindingElements"); } foreach (BindingElement element in bindingElementsInTopDownChannelStackOrder) { this.bindingElements.Add(element); } }
private MessageEncodingBindingElement FindMessageEncodingBindingElement(BindingElementCollection bindingElements, out bool createdNew) { createdNew = false; MessageEncodingBindingElement encodingBindingElement = bindingElements.Find <MessageEncodingBindingElement>(); if (encodingBindingElement == null) { createdNew = true; encodingBindingElement = new BinaryMessageEncodingBindingElement(); } return(encodingBindingElement); }
private void AddDemuxerBindingElement(BindingElementCollection elements) { if (elements.Find <ChannelDemuxerBindingElement>() == null) { TransportBindingElement item = elements.Find <TransportBindingElement>(); if (item == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("TransportBindingElementNotFound"))); } elements.Insert(elements.IndexOf(item), new ChannelDemuxerBindingElement(true)); } }
BuildInnerChannelFactory <TChannel> () { bool restore = PrepareElements(); try { return(DequeueBindingElement().BuildChannelFactory <TChannel> (this)); } finally { if (restore) { elements = empty_collection; } } }
internal CustomBinding(BindingElementCollection bindingElements) : base() { if (bindingElements == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(bindingElements)); } for (int i = 0; i < bindingElements.Count; i++) { Elements.Add(bindingElements[i]); } }
void IWsdlImportExtension.ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext context) { if (context == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context"); } #pragma warning suppress 56506 // Microsoft, these properties cannot be null in this context if (context.Endpoint.Binding == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context.Endpoint.Binding"); } BindingElementCollection bindingElements = GetBindingElements(context); MessageEncodingBindingElement messageEncodingBindingElement = bindingElements.Find <MessageEncodingBindingElement>(); TextMessageEncodingBindingElement textEncodingBindingElement = messageEncodingBindingElement as TextMessageEncodingBindingElement; if (messageEncodingBindingElement != null) { Type elementType = messageEncodingBindingElement.GetType(); if (elementType != typeof(TextMessageEncodingBindingElement) && elementType != typeof(BinaryMessageEncodingBindingElement) && elementType != typeof(MtomMessageEncodingBindingElement)) { return; } } EnsureMessageEncoding(context, messageEncodingBindingElement); foreach (OperationBinding wsdlOperationBinding in context.WsdlBinding.Operations) { OperationDescription operation = context.GetOperationDescription(wsdlOperationBinding); for (int i = 0; i < operation.Messages.Count; i++) { MessageDescription message = operation.Messages[i]; MessageBinding wsdlMessageBinding = context.GetMessageBinding(message); ImportMessageSoapAction(context.ContractConversionContext, message, wsdlMessageBinding, i != 0 /*isResponse*/); } foreach (FaultDescription fault in operation.Faults) { FaultBinding wsdlFaultBinding = context.GetFaultBinding(fault); if (wsdlFaultBinding != null) { ImportFaultSoapAction(context.ContractConversionContext, fault, wsdlFaultBinding); } } } }
BuildInnerChannelListener <TChannel> () where TChannel : class, IChannel { bool restore = PrepareElements(); try { return(DequeueBindingElement().BuildChannelListener <TChannel> (this)); } finally { if (restore) { elements = empty_collection; } } }
public T GetInnerProperty <T> () where T : class { bool restore = PrepareElements(); try { BindingElement e = DequeueBindingElement(false); return(e == null ? default(T) : e.GetProperty <T> (this)); } finally { if (restore) { elements = empty_collection; } } }
void AddDemuxerBindingElement(BindingElementCollection elements) { if (elements.Find <ChannelDemuxerBindingElement>() == null) { // add the channel demuxer binding element right above the transport TransportBindingElement transport = elements.Find <TransportBindingElement>(); if (transport == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.TransportBindingElementNotFound))); } // cache the context state in the demuxer so that the same context state can be provided to the transport // when building auxilliary channels and listeners (for ex, for security negotiation) elements.Insert(elements.IndexOf(transport), new ChannelDemuxerBindingElement(true)); } }
private static void ImportAddress(WsdlEndpointConversionContext context, TransportBindingElement transportBindingElement) { EndpointAddress address = context.Endpoint.Address = WsdlImporter.WSAddressingHelper.ImportAddress(context.WsdlPort); if (address != null) { context.Endpoint.Address = address; if ((address.Uri.Scheme == Uri.UriSchemeHttps) && !(transportBindingElement is HttpsTransportBindingElement)) { BindingElementCollection elements = ConvertToCustomBinding(context).Elements; elements.Remove(transportBindingElement); elements.Add(CreateHttpsFromHttp(transportBindingElement as HttpTransportBindingElement)); } } }
void IWsdlImportExtension.ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext endpointContext) { if (endpointContext == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("endpointContext"); } if (endpointContext.Endpoint.Binding == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("endpointContext.Binding"); } if (endpointContext.Endpoint.Binding is CustomBinding) { System.ServiceModel.Channels.Binding binding; BindingElementCollection elements = ((CustomBinding)endpointContext.Endpoint.Binding).Elements; TransportBindingElement element = elements.Find <TransportBindingElement>(); if (element is HttpTransportBindingElement) { if (WSHttpBindingBase.TryCreate(elements, out binding)) { this.SetBinding(endpointContext.Endpoint, binding); } else if (WSDualHttpBinding.TryCreate(elements, out binding)) { this.SetBinding(endpointContext.Endpoint, binding); } else if (BasicHttpBinding.TryCreate(elements, out binding)) { this.SetBinding(endpointContext.Endpoint, binding); } } else if ((element is MsmqTransportBindingElement) && NetMsmqBinding.TryCreate(elements, out binding)) { this.SetBinding(endpointContext.Endpoint, binding); } else if ((element is NamedPipeTransportBindingElement) && NetNamedPipeBinding.TryCreate(elements, out binding)) { this.SetBinding(endpointContext.Endpoint, binding); } else if ((element is PeerTransportBindingElement) && NetPeerTcpBinding.TryCreate(elements, out binding)) { this.SetBinding(endpointContext.Endpoint, binding); } else if ((element is TcpTransportBindingElement) && NetTcpBinding.TryCreate(elements, out binding)) { this.SetBinding(endpointContext.Endpoint, binding); } } }
private CustomBinding(IEnumerable <BindingElement> binding, string name, string ns) : base(name, ns) { elements = new BindingElementCollection(binding); foreach (BindingElement be in elements) { TransportBindingElement tbe = be as TransportBindingElement; if (tbe == null) { continue; } scheme = tbe.Scheme; break; } }
static void ImportAddress(WsdlEndpointConversionContext context, TransportBindingElement transportBindingElement) { EndpointAddress address = context.Endpoint.Address = WsdlImporter.WSAddressingHelper.ImportAddress(context.WsdlPort); if (address != null) { context.Endpoint.Address = address; // Replace the http BE with https BE only if the uri scheme is https and the transport binding element is a HttpTransportBindingElement but not HttpsTransportBindingElement if (address.Uri.Scheme == Uri.UriSchemeHttps && transportBindingElement is HttpTransportBindingElement && !(transportBindingElement is HttpsTransportBindingElement)) { BindingElementCollection elements = ConvertToCustomBinding(context).Elements; elements.Remove(transportBindingElement); elements.Add(CreateHttpsFromHttp(transportBindingElement as HttpTransportBindingElement)); } } }
internal void EnsureInvariants(string contractName) { BindingElementCollection elements = this.CreateBindingElements(); TransportBindingElement transport = null; int index; for (index = 0; index < elements.Count; index++) { transport = elements[index] as TransportBindingElement; if (transport != null) { break; } } if (transport == null) { if (contractName == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException( SR.Format(SR.CustomBindingRequiresTransport, this.Name))); } else { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException( SR.Format(SR.SFxCustomBindingNeedsTransport1, contractName))); } } if (index != elements.Count - 1) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException( SR.Format(SR.TransportBindingElementMustBeLast, this.Name, transport.GetType().Name))); } if (string.IsNullOrEmpty(transport.Scheme)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException( SR.Format(SR.InvalidBindingScheme, transport.GetType().Name))); } if (this.MessageVersion == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException( SR.Format(SR.MessageVersionMissingFromBinding, this.Name))); } }
void IWsdlImportExtension.ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext endpointContext) { if (endpointContext == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("endpointContext"); } #pragma warning disable 56506 // elenak, endpointContext.Endpoint is never null if (endpointContext.Endpoint.Binding == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("endpointContext.Binding"); } if (endpointContext.Endpoint.Binding is CustomBinding) { BindingElementCollection elements = ((CustomBinding)endpointContext.Endpoint.Binding).Elements; Binding binding = null; TransportBindingElement transport = elements.Find <TransportBindingElement>(); if (transport is HttpTransportBindingElement) { if (WSHttpBindingBase.TryCreate(elements, out binding)) { SetBinding(endpointContext.Endpoint, binding); } else if (BasicHttpBinding.TryCreate(elements, out binding)) { SetBinding(endpointContext.Endpoint, binding); } else if (NetHttpBinding.TryCreate(elements, out binding)) { SetBinding(endpointContext.Endpoint, binding); } } else if (transport is TcpTransportBindingElement && NetTcpBinding.TryCreate(elements, out binding)) { SetBinding(endpointContext.Endpoint, binding); } } }
void IPolicyExportExtension.ExportPolicy(MetadataExporter exporter, PolicyConversionContext context) { if (exporter == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context"); } if (context == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("context"); } if (context.BindingElements != null) { BindingElementCollection bindingElements = context.BindingElements; ReliableSessionBindingElement element = bindingElements.Find <ReliableSessionBindingElement>(); if (element != null) { XmlElement item = element.CreateReliabilityAssertion(exporter.PolicyVersion, bindingElements); context.GetBindingAssertions().Add(item); } } }
private NetTcpBinding CreateTcpBinding() { NetTcpBinding tcpBinding = new NetTcpBinding(); System.ServiceModel.Channels.BindingElementCollection bElementCollection = tcpBinding.CreateBindingElements(); tcpBinding.Name = "SeymourSkinner"; tcpBinding.CloseTimeout = TimeSpan.FromHours(2); // new TimeSpan(1, 0, 0); // 1 hora tcpBinding.OpenTimeout = TimeSpan.FromHours(2); // new TimeSpan(1, 0, 0); // 1 hora tcpBinding.ReceiveTimeout = TimeSpan.FromHours(2); // new TimeSpan(1, 0, 0); // 1 hora tcpBinding.SendTimeout = TimeSpan.FromHours(2); // new TimeSpan(1, 0, 0); // 1 hora tcpBinding.MaxBufferPoolSize = 2147483647; tcpBinding.MaxBufferSize = 2147483647; tcpBinding.MaxReceivedMessageSize = 2147483647; tcpBinding.ReliableSession.InactivityTimeout = new TimeSpan(1, 0, 0); tcpBinding.Security.Mode = SecurityMode.None; System.ServiceModel.Channels.TcpTransportBindingElement tcp = bElementCollection.Find <System.ServiceModel.Channels.TcpTransportBindingElement>(); tcp.ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint = 500; tcp.ConnectionPoolSettings.LeaseTimeout = TimeSpan.MaxValue; tcp.ConnectionPoolSettings.IdleTimeout = TimeSpan.MaxValue; tcp.ChannelInitializationTimeout = TimeSpan.MaxValue; tcp.ConnectionBufferSize = int.MaxValue; tcp.MaxBufferPoolSize = long.MaxValue; tcp.MaxBufferSize = int.MaxValue; tcp.MaxReceivedMessageSize = long.MaxValue; XmlDictionaryReaderQuotas quotas = tcpBinding.ReaderQuotas; quotas.MaxStringContentLength = int.MaxValue; quotas.MaxArrayLength = int.MaxValue; quotas.MaxBytesPerRead = int.MaxValue; quotas.MaxDepth = int.MaxValue; quotas.MaxNameTableCharCount = int.MaxValue; tcpBinding.GetType().GetProperty("ReaderQuotas").SetValue(tcpBinding, quotas, null); return(tcpBinding); }
public void ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext context) { if (context == null) { throw FxTrace.Exception.ArgumentNull("context"); } if (context.Endpoint.Binding == null) { throw FxTrace.Exception.ArgumentNull("context.Endpoint.Binding"); } BindingElementCollection bindingElements = context.Endpoint.Binding.CreateBindingElements(); TransportBindingElement transportBindingElement = bindingElements.Find <TransportBindingElement>(); if (transportBindingElement is UdpTransportBindingElement) { ImportEndpointAddress(context); } if (context.Endpoint.Binding is CustomBinding) { Binding newEndpointBinding = null; if (transportBindingElement is UdpTransportBindingElement) { Binding udpBinding; if (UdpBinding.TryCreate(bindingElements, out udpBinding)) { newEndpointBinding = udpBinding; } if (newEndpointBinding != null) { newEndpointBinding.Name = context.Endpoint.Binding.Name; newEndpointBinding.Namespace = context.Endpoint.Binding.Namespace; context.Endpoint.Binding = newEndpointBinding; } } } }
// deep clone .ctor(). BindingContext(CustomBinding binding, BindingParameterCollection parms, BindingElementCollection elems, Uri listenUriBaseAddress, string listenUriRelativeAddress, ListenUriMode listenUriMode) { this.binding = new CustomBinding(binding); parameters = new BindingParameterCollection(); foreach (var item in parms) { parameters.Add(item); } this.elements = new BindingElementCollection(); foreach (var item in elems) { this.elements.Add(item); } listen_uri_base = listenUriBaseAddress; listen_uri_relative = listenUriRelativeAddress; listen_uri_mode = listenUriMode; }
internal CustomBinding(Binding binding, BindingElementCollection elements) { this.bindingElements = new BindingElementCollection(); if (binding == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("binding"); } if (elements == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("elements"); } base.Name = binding.Name; base.Namespace = binding.Namespace; base.CloseTimeout = binding.CloseTimeout; base.OpenTimeout = binding.OpenTimeout; base.ReceiveTimeout = binding.ReceiveTimeout; base.SendTimeout = binding.SendTimeout; for (int i = 0; i < elements.Count; i++) { this.bindingElements.Add(elements[i]); } }