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); }
private void SetFromBuffer(ByteBuffer buffer, uint length) { bool trace = _log.IsDebugEnabled; if (length > 0) { int expectedRemaining = buffer.Remaining - (int)length; _properties = new LinkedHashtable(); do { string key = EncodingUtils.ReadShortString(buffer); AMQTypedValue value = AMQTypedValue.ReadFromBuffer(buffer); if (trace) { _log.Debug(string.Format("FieldTable::PropFieldTable(buffer,{0}): Read type '{1}', key '{2}', value '{3}'", length, value.Type, key, value.Value)); } _properties.Add(key, value); } while (buffer.Remaining > expectedRemaining); _encodedSize = length; } if (trace) { _log.Debug("FieldTable::FieldTable(buffer," + length + "): Done."); } }
// // 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); }
public void WritePayload(ByteBuffer buffer) { if (_encodedForm != null) { lock ( _syncLock ) { buffer.Put(_encodedForm); _encodedForm.Flip(); } } else if (_properties != null) { foreach (DictionaryEntry de in _properties) { string key = (string)de.Key; AMQTypedValue value = (AMQTypedValue)de.Value; try { if (_log.IsDebugEnabled) { _log.Debug("Writing Property:" + key + " Type:" + value.Type + " Value:" + value.Value); _log.Debug("Buffer Position:" + buffer.Position + " Remaining:" + buffer.Remaining); } //Write the actual parameter name EncodingUtils.WriteShortStringBytes(buffer, key); value.WriteToBuffer(buffer); } catch (Exception ex) { if (_log.IsDebugEnabled) { _log.Debug("Exception thrown:" + ex); _log.Debug("Writing Property:" + key + " Type:" + value.Type + " Value:" + value.Value); _log.Debug("Buffer Position:" + buffer.Position + " Remaining:" + buffer.Remaining); } throw; } } } }
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; }
private object GetObject(string key) { AMQTypedValue value = GetProperty(key); return(value != null ? value.Value : null); }