public BindingElementCollection Extend(BindingElementCollection bindingElementCollection) { MessageEncodingBindingElement item = bindingElementCollection.Find<MessageEncodingBindingElement>(); if (item != null) { ConfigureFromMessageEncodingBindingElement(item); int index = bindingElementCollection.IndexOf(item); bindingElementCollection.RemoveAt(index); bindingElementCollection.Insert(index, this); return bindingElementCollection; } bindingElementCollection.Insert(0, this); return bindingElementCollection; }
public BindingElementCollection Extend(BindingElementCollection bindingElementCollection) { MessageEncodingBindingElement item = bindingElementCollection.Find <MessageEncodingBindingElement>(); if (item != null) { ConfigureFromMessageEncodingBindingElement(item); int index = bindingElementCollection.IndexOf(item); bindingElementCollection.RemoveAt(index); bindingElementCollection.Insert(index, this); return(bindingElementCollection); } bindingElementCollection.Insert(0, this); return(bindingElementCollection); }
public override BindingElementCollection CreateBindingElements() { BindingElementCollection elements = base.CreateBindingElements(); elements.Insert(0, new ContextBindingElement(this.ContextProtectionLevel, ContextExchangeMechanism.ContextSoapHeader, this.ClientCallbackAddress, this.ContextManagementEnabled)); return(elements); }
public override BindingElementCollection CreateBindingElements() { BindingElementCollection bindingElements = base.CreateBindingElements(); bindingElements.Insert(bindingElements.Count - 1, channelBindingElement); return(bindingElements); }
//The heart of the custom binding public override BindingElementCollection CreateBindingElements() { BindingElement element = new ContextBindingElement(ContextProtectionLevel, ContextExchangeMechanism.ContextSoapHeader); BindingElementCollection elements = base.CreateBindingElements(); elements.Insert(0, element); return(elements); }
public override BindingElementCollection CreateBindingElements() { BindingElementCollection bindingElementCollection = base.CreateBindingElements(); if (this.reliableSession.Enabled) { bindingElementCollection.Insert(0, this.session); } return(bindingElementCollection.Clone()); }
public override BindingElementCollection CreateBindingElements() { BindingElementCollection elements = base.CreateBindingElements(); PrivacyNoticeBindingElement item = this.CreatePrivacyPolicy(); if (item != null) { elements.Insert(0, item); } return(elements); }
private 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.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)); } }
public override BindingElementCollection CreateBindingElements() { // return collection of BindingElements BindingElementCollection bindingElements = base.CreateBindingElements(); // order of BindingElements is important PrivacyNoticeBindingElement privacy = this.CreatePrivacyPolicy(); if (privacy != null) { // This must go first. bindingElements.Insert(0, privacy); } return(bindingElements); }
/// <summary> /// Cria um binding para comunicação. /// </summary> /// <param name="securityMode">Modo de segurança.</param> /// <param name="requireClientCertificates"></param> /// <returns></returns> public static Binding CreateBinding(SecurityMode securityMode, bool requireClientCertificates) { WSHttpBinding binding = new WSHttpBinding(securityMode); binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; binding.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max; binding.MaxReceivedMessageSize = System.Xml.XmlDictionaryReaderQuotas.Max.MaxStringContentLength; Binding binding2 = binding; if ((securityMode == SecurityMode.Transport) && requireClientCertificates) { binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate; BindingElementCollection bindingElementsInTopDownChannelStackOrder = binding.CreateBindingElements(); TransportSecurityBindingElement item = new TransportSecurityBindingElement(); System.ServiceModel.Security.Tokens.X509SecurityTokenParameters parameters = new System.ServiceModel.Security.Tokens.X509SecurityTokenParameters(); parameters.InclusionMode = System.ServiceModel.Security.Tokens.SecurityTokenInclusionMode.AlwaysToRecipient; item.EndpointSupportingTokenParameters.Endorsing.Add(parameters); bindingElementsInTopDownChannelStackOrder.Insert(bindingElementsInTopDownChannelStackOrder.Count - 1, item); binding2 = new CustomBinding(bindingElementsInTopDownChannelStackOrder); } return(binding2); }
/// <summary> /// Returns an ordered collection of binding elements contained in the current binding. /// </summary> public override BindingElementCollection CreateBindingElements() { BindingElementCollection elements = base.CreateBindingElements(); if (this.BinaryEncoding) { // search the existing message encoding element (Text or MTOM) and replace it // note: the search must be done with the base type of text and mtom binding element, // because this code is compiled against silverlight also // and there is no mtom encoding available for (int i = elements.Count - 1; i >= 0; i--) { BindingElement element = elements[i]; if (element.GetType().IsSubclassOf(typeof(MessageEncodingBindingElement))) { BinaryMessageEncodingBindingElement binaryElement = null; var textEncoding = element as TextMessageEncodingBindingElement; var mtomEncoding = element as MtomMessageEncodingBindingElement; if (textEncoding != null) { // copy settings to binary element binaryElement = new BinaryMessageEncodingBindingElement(); // copy settings binaryElement.ReaderQuotas.MaxArrayLength = textEncoding.ReaderQuotas.MaxArrayLength; binaryElement.ReaderQuotas.MaxBytesPerRead = textEncoding.ReaderQuotas.MaxBytesPerRead; binaryElement.ReaderQuotas.MaxDepth = textEncoding.ReaderQuotas.MaxDepth; binaryElement.ReaderQuotas.MaxNameTableCharCount = textEncoding.ReaderQuotas.MaxNameTableCharCount; binaryElement.ReaderQuotas.MaxStringContentLength = textEncoding.ReaderQuotas.MaxStringContentLength; binaryElement.MaxReadPoolSize = textEncoding.MaxReadPoolSize; binaryElement.MaxWritePoolSize = textEncoding.MaxWritePoolSize; // binary uses always soap-1.2 //binaryElement.MessageVersion = textEncoding.MessageVersion; } else if (mtomEncoding != null) { // copy settings to binary element binaryElement = new BinaryMessageEncodingBindingElement(); // copy settings binaryElement.ReaderQuotas.MaxArrayLength = mtomEncoding.ReaderQuotas.MaxArrayLength; binaryElement.ReaderQuotas.MaxBytesPerRead = mtomEncoding.ReaderQuotas.MaxBytesPerRead; binaryElement.ReaderQuotas.MaxDepth = mtomEncoding.ReaderQuotas.MaxDepth; binaryElement.ReaderQuotas.MaxNameTableCharCount = mtomEncoding.ReaderQuotas.MaxNameTableCharCount; binaryElement.ReaderQuotas.MaxStringContentLength = mtomEncoding.ReaderQuotas.MaxStringContentLength; binaryElement.MaxReadPoolSize = mtomEncoding.MaxReadPoolSize; binaryElement.MaxWritePoolSize = mtomEncoding.MaxWritePoolSize; // binary uses always soap-1.2 //binaryElement.MessageVersion = mtomEncoding.MessageVersion; } else if (element is BinaryMessageEncodingBindingElement) { // it's already binary } else { string exStr = string.Format(CultureInfo.CurrentCulture, "Message encoding type {0} is not implemented.", element.GetType().Name); throw new NotImplementedException(exStr); } if (binaryElement != null) { elements.RemoveAt(i); elements.Insert(i, binaryElement); break; } } } } return(elements); }