public override T GetProperty <T>(BindingContext context)
        {
            if (context == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(context));
            }

            if (typeof(T) == typeof(ChannelProtectionRequirements))
            {
                AddressingVersion             addressing = MessageVersion.Default.Addressing;
                MessageEncodingBindingElement encoding   = context.Binding.Elements.Find <MessageEncodingBindingElement>();
                if (encoding != null)
                {
                    addressing = encoding.MessageVersion.Addressing;
                }

                ChannelProtectionRequirements myRequirements = GetProtectionRequirements(addressing, ProtectionLevel.EncryptAndSign);
                myRequirements.Add(context.GetInnerProperty <ChannelProtectionRequirements>() ?? new ChannelProtectionRequirements());
                return((T)(object)myRequirements);
            }
            else
            {
                return(base.GetProperty <T>(context));
            }
        }
示例#2
0
        protected override bool IsMatch(BindingElement b)
        {
            MessageEncodingBindingElement encoding = b as MessageEncodingBindingElement;

            if (encoding == null)
            {
                return(false);
            }

            return(true);
        }
示例#3
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);
            }
        }
示例#4
0
 protected MessageEncodingBindingElement(MessageEncodingBindingElement elementToBeCloned)
     : base(elementToBeCloned)
 {
 }