Beispiel #1
0
        private AMQTypedValue SetProperty(string key, AMQTypedValue value)
        {
            InitMapIfNecessary();
            _encodedForm = null;
            if (value == null)
            {
                RemoveKey(key);
            }
            AMQTypedValue oldVal = (AMQTypedValue)_properties[key];

            _properties.Add(key, value);
            if (oldVal != null)
            {
                _encodedSize -= oldVal.EncodingLength;
            }
            else
            {
                _encodedSize += EncodingUtils.EncodedShortStringLength(key) + (uint)1;
            }
            if (value != null)
            {
                _encodedSize += value.EncodingLength;
            }

            return(oldVal);
        }
Beispiel #2
0
        //
        // Public Methods
        //

        /// <summary>
        /// Removes the property with the specified name
        /// </summary>
        /// <param name="key">The name of the property to remove</param>
        /// <returns>The previous value of the property or null</returns>
        public AMQTypedValue RemoveKey(string key)
        {
            InitMapIfNecessary();
            _encodedForm = null;
            AMQTypedValue value = (AMQTypedValue)_properties[key];

            if (value != null)
            {
                _properties.Remove(key);
                _encodedSize -= EncodingUtils.EncodedShortStringLength(key);
                _encodedSize--;
                _encodedSize -= value.EncodingLength;
            }
            return(value);
        }