Beispiel #1
0
 BindingContext(CustomBinding binding,
                BindingElementCollection remainingBindingElements,
                BindingParameterCollection parameters,
                Uri listenUriBaseAddress,
                string listenUriRelativeAddress,
                ListenUriMode listenUriMode)
 {
     Initialize(binding, remainingBindingElements, parameters, listenUriBaseAddress, listenUriRelativeAddress, listenUriMode);
 }
        // returns a new collection with clones of all the elements
        public BindingElementCollection Clone()
        {
            BindingElementCollection result = new BindingElementCollection();

            for (int i = 0; i < Count; i++)
            {
                result.Add(this[i].Clone());
            }
            return(result);
        }
Beispiel #3
0
        internal BindingElementCollection Reverse()
        {
            var bec = new BindingElementCollection();

            for (int i = Count - 1; i >= 0; i--)
            {
                bec.Add(this[i]);
            }

            return(bec);
        }
Beispiel #4
0
 private void Initialize(CustomBinding binding,
                         BindingElementCollection remainingBindingElements,
                         BindingParameterCollection parameters,
                         Uri listenUriBaseAddress,
                         string listenUriRelativeAddress)
 {
     Binding = binding;
     RemainingBindingElements = new BindingElementCollection(remainingBindingElements);
     BindingParameters        = new BindingParameterCollection(parameters);
     ListenUriBaseAddress     = listenUriBaseAddress;
     ListenUriRelativeAddress = listenUriRelativeAddress;
 }
Beispiel #5
0
        private void Initialize(CustomBinding binding,
                                BindingElementCollection remainingBindingElements,
                                BindingParameterCollection parameters,
                                Uri listenUriBaseAddress,
                                string listenUriRelativeAddress,
                                ListenUriMode listenUriMode)
        {
            _binding = binding;

            _remainingBindingElements = new BindingElementCollection(remainingBindingElements);
            _bindingParameters        = new BindingParameterCollection(parameters);
            _listenUriBaseAddress     = listenUriBaseAddress;
            _listenUriRelativeAddress = listenUriRelativeAddress;
            _listenUriMode            = listenUriMode;
        }
Beispiel #6
0
        internal void EnsureInvariants(string contractName)
        {
            BindingElementCollection elements  = 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, 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, Name, transport.GetType().Name)));
            }
            if (string.IsNullOrEmpty(transport.Scheme))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
                                                                              SR.Format(SR.InvalidBindingScheme, transport.GetType().Name)));
            }

            if (MessageVersion == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(
                                                                              SR.Format(SR.MessageVersionMissingFromBinding, Name)));
            }
        }
Beispiel #7
0
        private static BindingContext CreateIssuerBindingContextForNegotiation(BindingContext issuerBindingContext)
        {
            TransportBindingElement transport = issuerBindingContext.RemainingBindingElements.Find <TransportBindingElement>();

            if (transport == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.TransportBindingElementNotFound)));
            }
            //ChannelDemuxerBindingElement demuxer = null;
            //// pick the demuxer above transport (i.e. the last demuxer in the array)
            //for (int i = 0; i < issuerBindingContext.RemainingBindingElements.Count; ++i)
            //{
            //    if (issuerBindingContext.RemainingBindingElements[i] is ChannelDemuxerBindingElement)
            //    {
            //        demuxer = (ChannelDemuxerBindingElement)issuerBindingContext.RemainingBindingElements[i];
            //    }
            //}
            //if (demuxer == null)
            //{
            //    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.ChannelDemuxerBindingElementNotFound)));
            //}
            BindingElementCollection negotiationBindingElements = new BindingElementCollection
            {
                //negotiationBindingElements.Add(demuxer.Clone());
                transport.Clone()
            };
            CustomBinding binding = new CustomBinding(negotiationBindingElements)
            {
                OpenTimeout    = issuerBindingContext.Binding.OpenTimeout,
                CloseTimeout   = issuerBindingContext.Binding.CloseTimeout,
                SendTimeout    = issuerBindingContext.Binding.SendTimeout,
                ReceiveTimeout = issuerBindingContext.Binding.ReceiveTimeout
            };

            if (issuerBindingContext.ListenUriBaseAddress != null)
            {
                return(new BindingContext(binding, new BindingParameterCollection(issuerBindingContext.BindingParameters), issuerBindingContext.ListenUriBaseAddress,
                                          issuerBindingContext.ListenUriRelativeAddress));//, issuerBindingContext.ListenUriMode);
            }
            else
            {
                return(new BindingContext(binding, new BindingParameterCollection(issuerBindingContext.BindingParameters)));
            }
        }
Beispiel #8
0
        private void BuildHandler()
        {
            BindingElementCollection      be   = _serviceDispatcher.Binding.CreateBindingElements();
            MessageEncodingBindingElement mebe = be.Find <MessageEncodingBindingElement>();

            if (mebe == null)
            {
                throw new ArgumentException("Must provide a MessageEncodingBindingElement", nameof(_serviceDispatcher.Binding));
            }

            HttpTransportBindingElement tbe = be.Find <HttpTransportBindingElement>();

            if (tbe == null)
            {
                throw new ArgumentException("Must provide a HttpTransportBindingElement", nameof(_serviceDispatcher.Binding));
            }

            var httpSettings = new HttpTransportSettings
            {
                BufferManager             = BufferManager.CreateBufferManager(DefaultMaxBufferPoolSize, tbe.MaxBufferSize),
                OpenTimeout               = _serviceDispatcher.Binding.OpenTimeout,
                ReceiveTimeout            = _serviceDispatcher.Binding.ReceiveTimeout,
                SendTimeout               = _serviceDispatcher.Binding.SendTimeout,
                CloseTimeout              = _serviceDispatcher.Binding.CloseTimeout,
                MaxBufferSize             = tbe.MaxBufferSize,
                MaxReceivedMessageSize    = tbe.MaxReceivedMessageSize,
                MessageEncoderFactory     = mebe.CreateMessageEncoderFactory(),
                ManualAddressing          = tbe.ManualAddressing,
                TransferMode              = tbe.TransferMode,
                KeepAliveEnabled          = tbe.KeepAliveEnabled,
                AnonymousUriPrefixMatcher = new HttpAnonymousUriPrefixMatcher(),
                AuthenticationScheme      = tbe.AuthenticationScheme,
                WebSocketSettings         = tbe.WebSocketSettings.Clone()
            };

            _httpSettings    = httpSettings;
            WebSocketOptions = CreateWebSocketOptions(tbe);

            if (WebSocketOptions == null)
            {
                _replyChannel = new AspNetCoreReplyChannel(_servicesScopeFactory.CreateScope().ServiceProvider, _httpSettings);
                _replyChannelDispatcherTask = _serviceDispatcher.CreateServiceChannelDispatcherAsync(_replyChannel);
            }
        }
Beispiel #9
0
        internal CustomBinding(Binding binding, BindingElementCollection elements)
        {
            if (binding == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(binding));
            }
            if (elements == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(elements));
            }

            Name           = binding.Name;
            Namespace      = binding.Namespace;
            CloseTimeout   = binding.CloseTimeout;
            OpenTimeout    = binding.OpenTimeout;
            ReceiveTimeout = binding.ReceiveTimeout;
            SendTimeout    = binding.SendTimeout;

            for (int i = 0; i < elements.Count; i++)
            {
                Elements.Add(elements[i]);
            }
        }