Esempio n. 1
0
        internal static bool TryGet(MessageProperties properties, out WebSocketMessageProperty property)
        {
            if (properties == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(properties));
            }

            property = null;
            object foundProperty;

            if (properties.TryGetValue(Name, out foundProperty))
            {
                property = (WebSocketMessageProperty)foundProperty;
                return(true);
            }
            return(false);
        }
Esempio n. 2
0
        public static bool TryGet(MessageProperties properties, out ReceiveContext property)
        {
            if (properties == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("properties");
            }

            property = null;
            object foundProperty;

            if (properties.TryGetValue(Name, out foundProperty))
            {
                property = (ReceiveContext)foundProperty;
                return(true);
            }
            return(false);
        }
        public static bool TryGet(MessageProperties properties, out ChannelBindingMessageProperty property)
        {
            if (properties == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(properties));
            }

            property = null;

            if (properties.TryGetValue(Name, out object value))
            {
                property = value as ChannelBindingMessageProperty;
                return(property != null);
            }

            return(false);
        }
Esempio n. 4
0
        internal void MergeProperties(MessageProperties properties)
        {
            // MergeProperties behavior should be equivalent to the behavior
            // of CopyProperties except that Merge supports property values that
            // implement the IMergeEnabledMessageProperty.  Any changes to CopyProperties
            // should be reflected in MergeProperties as well.
            if (properties == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("properties");
            }

            if (disposed)
            {
                ThrowDisposed();
            }

            if (properties.properties != null)
            {
                for (int i = 0; i < properties.properties.Length; i++)
                {
                    if (properties.properties[i].Name == null)
                    {
                        break;
                    }

                    Property property = properties.properties[i];

                    // Used with Http transport
                    //IMergeEnabledMessageProperty currentValue;
                    //if (!this.TryGetValue<IMergeEnabledMessageProperty>(property.Name, out currentValue) ||
                    //    !currentValue.TryMergeWithProperty(property.Value))
                    //{
                    // Merge wasn't possible so copy
                    // this[string] will call CreateCopyOfPropertyValue, so we don't need to repeat that here
                    this[property.Name] = property.Value;
                    //}
                }
            }

            Via = properties.Via;
            AllowOutputBatching = properties.AllowOutputBatching;
            //this.Security = (properties.Security != null) ? (SecurityMessageProperty)properties.Security.CreateCopy() : null;
            Encoder = properties.Encoder;
        }
            private void AddMessageProperties(MessageProperties messageProperties, WebSocketMessageType incomingMessageType)
            {
                Fx.Assert(messageProperties != null, "messageProperties should not be null.");
                WebSocketMessageProperty messageProperty = new WebSocketMessageProperty(
                    _context,
                    _webSocket.SubProtocol,
                    incomingMessageType,
                    _properties);

                messageProperties.Add(WebSocketMessageProperty.Name, messageProperty);

                if (RemoteEndpointMessageProperty != null)
                {
                    messageProperties.Add(RemoteEndpointMessageProperty.Name, RemoteEndpointMessageProperty);
                }

                if (_handshakeSecurityMessageProperty != null)
                {
                    messageProperties.Security = (SecurityMessageProperty)_handshakeSecurityMessageProperty.CreateCopy();
                }
            }
Esempio n. 6
0
        public void CopyProperties(MessageProperties properties)
        {
            // CopyProperties behavior should be equivalent to the behavior
            // of MergeProperties except that Merge supports property values that
            // implement the IMergeEnabledMessageProperty.  Any changes to CopyProperties
            // should be reflected in MergeProperties as well.
            if (properties == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("properties");
            }

            if (disposed)
            {
                ThrowDisposed();
            }

            if (properties.properties != null)
            {
                for (int i = 0; i < properties.properties.Length; i++)
                {
                    if (properties.properties[i].Name == null)
                    {
                        break;
                    }

                    Property property = properties.properties[i];

                    // this[string] will call CreateCopyOfPropertyValue, so we don't need to repeat that here
                    this[property.Name] = property.Value;
                }
            }

            Via = properties.Via;
            AllowOutputBatching = properties.AllowOutputBatching;
            //this.Security = (properties.Security != null) ? (SecurityMessageProperty)properties.Security.CreateCopy() : null;
            Encoder = properties.Encoder;
        }
 public void UpdateOpenNotificationMessageProperties(MessageProperties messageProperties)
 {
     AddMessageProperties(messageProperties, WebSocketDefaults.DefaultWebSocketMessageType);
 }
 public override void UpdateMessageProperties(MessageProperties inboundMessageProperties)
 {
     this.channel.webSocketMessageSource.UpdateOpenNotificationMessageProperties(inboundMessageProperties);
 }
Esempio n. 9
0
 public MessageProperties(MessageProperties properties)
 {
     CopyProperties(properties);
 }