diff options
author | Robert Greig <rgreig@apache.org> | 2007-02-26 17:46:07 +0000 |
---|---|---|
committer | Robert Greig <rgreig@apache.org> | 2007-02-26 17:46:07 +0000 |
commit | a019367dc582d61fa3739f385592c0baf9b972b8 (patch) | |
tree | 5ce170123120f788d07d472e2febf6b32f17dc29 /qpid/dotnet/Qpid.Common | |
parent | 2e9743ac06fc05609155769bf04f4fa442d848c2 (diff) | |
download | qpid-python-a019367dc582d61fa3739f385592c0baf9b972b8.tar.gz |
(Patch submitted by Tomas Restrepo) QPID-ByteBuffer.diff.
Completely refactors the byte buffer implementation, doing away with a complex inheritance hierarchy.
Fixes reading and writing of field table to permit interop with Java client.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@511923 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/dotnet/Qpid.Common')
-rw-r--r-- | qpid/dotnet/Qpid.Common/Framing/AMQDataBlockDecoder.cs | 22 | ||||
-rw-r--r-- | qpid/dotnet/Qpid.Common/Framing/AMQDataBlockEncoder.cs | 4 | ||||
-rw-r--r-- | qpid/dotnet/Qpid.Common/Framing/AMQFrame.cs | 8 | ||||
-rw-r--r-- | qpid/dotnet/Qpid.Common/Framing/AMQMethodBody.cs | 4 | ||||
-rw-r--r-- | qpid/dotnet/Qpid.Common/Framing/AMQMethodBodyFactory.cs | 2 | ||||
-rw-r--r-- | qpid/dotnet/Qpid.Common/Framing/AMQType.cs | 6 | ||||
-rw-r--r-- | qpid/dotnet/Qpid.Common/Framing/AMQTypedValue.cs | 2 | ||||
-rw-r--r-- | qpid/dotnet/Qpid.Common/Framing/BasicContentHeaderProperties.cs | 18 | ||||
-rw-r--r-- | qpid/dotnet/Qpid.Common/Framing/ContentBody.cs | 4 | ||||
-rw-r--r-- | qpid/dotnet/Qpid.Common/Framing/ContentHeaderBody.cs | 16 | ||||
-rw-r--r-- | qpid/dotnet/Qpid.Common/Framing/EncodingUtils.cs | 99 | ||||
-rw-r--r-- | qpid/dotnet/Qpid.Common/Framing/FieldTable.cs | 29 | ||||
-rw-r--r-- | qpid/dotnet/Qpid.Common/Framing/HeartbeatBody.cs | 2 | ||||
-rw-r--r-- | qpid/dotnet/Qpid.Common/Framing/ProtocolInitiation.cs | 28 | ||||
-rw-r--r-- | qpid/dotnet/Qpid.Common/Qpid.Common.csproj | 1 | ||||
-rw-r--r-- | qpid/dotnet/Qpid.Common/stylesheets/utils.xsl | 18 |
16 files changed, 137 insertions, 126 deletions
diff --git a/qpid/dotnet/Qpid.Common/Framing/AMQDataBlockDecoder.cs b/qpid/dotnet/Qpid.Common/Framing/AMQDataBlockDecoder.cs index 2e373402b6..1c1080bdcb 100644 --- a/qpid/dotnet/Qpid.Common/Framing/AMQDataBlockDecoder.cs +++ b/qpid/dotnet/Qpid.Common/Framing/AMQDataBlockDecoder.cs @@ -51,11 +51,11 @@ namespace Qpid.Framing } // final +1 represents the command end which we know we must require even // if there is an empty body - if (input.remaining() < 1) + if (input.Remaining < 1) { return MessageDecoderResult.NEED_DATA; } - byte type = input.get(); + byte type = input.GetByte(); // we have to check this isn't a protocol initiation frame here - we can't tell later on and we end up // waiting for more data. This could be improved if MINA supported some kind of state awareness when decoding @@ -65,13 +65,13 @@ namespace Qpid.Framing return MessageDecoderResult.NOT_OK; } // zero, channel, body size and end byte - if (input.remaining() < (1 + 2 + 4 + 1)) + if (input.Remaining < (1 + 2 + 4 + 1)) { return MessageDecoderResult.NEED_DATA; } - - int channel = input.GetUnsignedShort(); - long bodySize = input.GetUnsignedInt(); + + int channel = input.GetUInt16(); + long bodySize = input.GetUInt32(); // bodySize can be zero if (type <= 0 || channel < 0 || bodySize < 0) @@ -80,7 +80,7 @@ namespace Qpid.Framing return MessageDecoderResult.NOT_OK; } - if (input.remaining() < (bodySize + 1)) + if (input.Remaining < (bodySize + 1)) { return MessageDecoderResult.NEED_DATA; } @@ -116,9 +116,9 @@ namespace Qpid.Framing protected Object CreateAndPopulateFrame(ByteBuffer input) { - byte type = input.get(); - ushort channel = input.GetUnsignedShort(); - uint bodySize = input.GetUnsignedInt(); + byte type = input.GetByte(); + ushort channel = input.GetUInt16(); + uint bodySize = input.GetUInt32(); IBodyFactory bodyFactory = (IBodyFactory)_supportedBodies[type]; if (bodyFactory == null) @@ -129,7 +129,7 @@ namespace Qpid.Framing frame.PopulateFromBuffer(input, channel, bodySize, bodyFactory); - byte marker = input.get(); + byte marker = input.GetByte(); if (marker != 0xCE) { throw new FormatException("marker is not 0xCE"); } diff --git a/qpid/dotnet/Qpid.Common/Framing/AMQDataBlockEncoder.cs b/qpid/dotnet/Qpid.Common/Framing/AMQDataBlockEncoder.cs index 6c30040167..b180e1ac95 100644 --- a/qpid/dotnet/Qpid.Common/Framing/AMQDataBlockEncoder.cs +++ b/qpid/dotnet/Qpid.Common/Framing/AMQDataBlockEncoder.cs @@ -51,14 +51,14 @@ namespace Qpid.Framing { IDataBlock frame = (IDataBlock) message; int frameSize = (int)frame.Size; // TODO: sort out signed/unsigned - ByteBuffer buffer = ByteBuffer.allocate(frameSize); + ByteBuffer buffer = ByteBuffer.Allocate(frameSize); frame.WritePayload(buffer); if (_logger.IsDebugEnabled) { _logger.Debug("Encoded frame byte-buffer is '" + ByteBufferHexDumper.GetHexDump(buffer) + "'"); } - buffer.flip(); + buffer.Flip(); output.Write(buffer); } } diff --git a/qpid/dotnet/Qpid.Common/Framing/AMQFrame.cs b/qpid/dotnet/Qpid.Common/Framing/AMQFrame.cs index 9652cdfabc..2708c331b3 100644 --- a/qpid/dotnet/Qpid.Common/Framing/AMQFrame.cs +++ b/qpid/dotnet/Qpid.Common/Framing/AMQFrame.cs @@ -74,12 +74,12 @@ namespace Qpid.Framing public void WritePayload(ByteBuffer buffer) { - buffer.put(_bodyFrame.BodyType); + buffer.Put(_bodyFrame.BodyType); // TODO: how does channel get populated - buffer.put(_channel); - buffer.put(_bodyFrame.Size); + buffer.Put(_channel); + buffer.Put(_bodyFrame.Size); _bodyFrame.WritePayload(buffer); - buffer.put((byte) 0xCE); + buffer.Put((byte) 0xCE); } #endregion diff --git a/qpid/dotnet/Qpid.Common/Framing/AMQMethodBody.cs b/qpid/dotnet/Qpid.Common/Framing/AMQMethodBody.cs index 96e8e60be1..804e6a4039 100644 --- a/qpid/dotnet/Qpid.Common/Framing/AMQMethodBody.cs +++ b/qpid/dotnet/Qpid.Common/Framing/AMQMethodBody.cs @@ -62,8 +62,8 @@ namespace Qpid.Framing public void WritePayload(ByteBuffer buffer) { - buffer.put(Clazz); - buffer.put(Method); + buffer.Put(Clazz); + buffer.Put(Method); WriteMethodPayload(buffer); } diff --git a/qpid/dotnet/Qpid.Common/Framing/AMQMethodBodyFactory.cs b/qpid/dotnet/Qpid.Common/Framing/AMQMethodBodyFactory.cs index 5df9720678..a5c90f0fdd 100644 --- a/qpid/dotnet/Qpid.Common/Framing/AMQMethodBodyFactory.cs +++ b/qpid/dotnet/Qpid.Common/Framing/AMQMethodBodyFactory.cs @@ -39,7 +39,7 @@ namespace Qpid.Framing /// <exception>AMQFrameDecodingException</exception> public IBody CreateBody(ByteBuffer inbuf) { - return MethodBodyDecoderRegistry.Get(inbuf.GetUnsignedShort(), inbuf.GetUnsignedShort()); + return MethodBodyDecoderRegistry.Get(inbuf.GetUInt16(), inbuf.GetUInt16()); } } } diff --git a/qpid/dotnet/Qpid.Common/Framing/AMQType.cs b/qpid/dotnet/Qpid.Common/Framing/AMQType.cs index 3bcc6c6222..8743ea0ea5 100644 --- a/qpid/dotnet/Qpid.Common/Framing/AMQType.cs +++ b/qpid/dotnet/Qpid.Common/Framing/AMQType.cs @@ -63,7 +63,7 @@ namespace Qpid.Framing /// <param name="buffer">Buffer to write to</param>
public void WriteToBuffer(object value, ByteBuffer buffer)
{
- buffer.put(Identifier);
+ buffer.Put(Identifier);
WriteValueImpl(value, buffer);
}
@@ -163,7 +163,7 @@ namespace Qpid.Framing sealed class AMQUInt32Type : AMQType
{
- public AMQUInt32Type() : base('I')
+ public AMQUInt32Type() : base('i')
{
}
@@ -560,7 +560,7 @@ namespace Qpid.Framing sealed class AMQInt32Type : AMQType
{
- public AMQInt32Type() : base('i')
+ public AMQInt32Type() : base('I')
{
}
diff --git a/qpid/dotnet/Qpid.Common/Framing/AMQTypedValue.cs b/qpid/dotnet/Qpid.Common/Framing/AMQTypedValue.cs index 08b5c1e6e9..7fdabbaf6c 100644 --- a/qpid/dotnet/Qpid.Common/Framing/AMQTypedValue.cs +++ b/qpid/dotnet/Qpid.Common/Framing/AMQTypedValue.cs @@ -64,7 +64,7 @@ namespace Qpid.Framing public static AMQTypedValue ReadFromBuffer(ByteBuffer buffer)
{
- AMQType type = AMQTypeMap.GetType(buffer.get());
+ AMQType type = AMQTypeMap.GetType(buffer.GetByte());
return new AMQTypedValue(type, buffer);
}
diff --git a/qpid/dotnet/Qpid.Common/Framing/BasicContentHeaderProperties.cs b/qpid/dotnet/Qpid.Common/Framing/BasicContentHeaderProperties.cs index 709db419c4..75d67fdfb8 100644 --- a/qpid/dotnet/Qpid.Common/Framing/BasicContentHeaderProperties.cs +++ b/qpid/dotnet/Qpid.Common/Framing/BasicContentHeaderProperties.cs @@ -41,7 +41,7 @@ namespace Qpid.Framing public string CorrelationId; - public uint Expiration; + public long Expiration; public string ReplyTo; @@ -102,13 +102,13 @@ namespace Qpid.Framing EncodingUtils.WriteShortStringBytes(buffer, ContentType); EncodingUtils.WriteShortStringBytes(buffer, Encoding); EncodingUtils.WriteFieldTableBytes(buffer, Headers); - buffer.put(DeliveryMode); - buffer.put(Priority); + buffer.Put(DeliveryMode); + buffer.Put(Priority); EncodingUtils.WriteShortStringBytes(buffer, CorrelationId); EncodingUtils.WriteShortStringBytes(buffer, ReplyTo); EncodingUtils.WriteShortStringBytes(buffer, String.Format("{0:D}", Expiration)); EncodingUtils.WriteShortStringBytes(buffer, MessageId); - buffer.put(Timestamp); + buffer.Put(Timestamp); EncodingUtils.WriteShortStringBytes(buffer, Type); EncodingUtils.WriteShortStringBytes(buffer, UserId); EncodingUtils.WriteShortStringBytes(buffer, AppId); @@ -125,19 +125,19 @@ namespace Qpid.Framing if ((propertyFlags & (1 << 13)) > 0) Headers = EncodingUtils.ReadFieldTable(buffer); if ((propertyFlags & (1 << 12)) > 0) - DeliveryMode = buffer.get(); + DeliveryMode = buffer.GetByte(); if ((propertyFlags & (1 << 11)) > 0) - Priority = buffer.get(); + Priority = buffer.GetByte(); if ((propertyFlags & (1 << 10)) > 0) CorrelationId = EncodingUtils.ReadShortString(buffer); if ((propertyFlags & (1 << 9)) > 0) ReplyTo = EncodingUtils.ReadShortString(buffer); if ((propertyFlags & (1 << 8)) > 0) - Expiration = UInt32.Parse(EncodingUtils.ReadShortString(buffer)); + Expiration = EncodingUtils.ReadLongAsShortString(buffer); if ((propertyFlags & (1 << 7)) > 0) MessageId = EncodingUtils.ReadShortString(buffer); - if ((propertyFlags & (1 << 6)) > 0) - Timestamp = buffer.GetUnsignedLong(); + if ((propertyFlags & (1 << 6)) > 0) + Timestamp = buffer.GetUInt64(); if ((propertyFlags & (1 << 5)) > 0) Type = EncodingUtils.ReadShortString(buffer); if ((propertyFlags & (1 << 4)) > 0) diff --git a/qpid/dotnet/Qpid.Common/Framing/ContentBody.cs b/qpid/dotnet/Qpid.Common/Framing/ContentBody.cs index 4e7ae2019a..b63df22339 100644 --- a/qpid/dotnet/Qpid.Common/Framing/ContentBody.cs +++ b/qpid/dotnet/Qpid.Common/Framing/ContentBody.cs @@ -54,7 +54,7 @@ namespace Qpid.Framing { if (Payload != null) { - buffer.put(Payload); + buffer.Put(Payload); } } @@ -63,7 +63,7 @@ namespace Qpid.Framing if (size > 0) { Payload = new byte[size]; - buffer.get(Payload); + buffer.GetBytes(Payload); } } diff --git a/qpid/dotnet/Qpid.Common/Framing/ContentHeaderBody.cs b/qpid/dotnet/Qpid.Common/Framing/ContentHeaderBody.cs index f72f6208bc..29ec46c0fb 100644 --- a/qpid/dotnet/Qpid.Common/Framing/ContentHeaderBody.cs +++ b/qpid/dotnet/Qpid.Common/Framing/ContentHeaderBody.cs @@ -73,19 +73,19 @@ namespace Qpid.Framing public void WritePayload(ByteBuffer buffer) { - buffer.put(ClassId); - buffer.put(Weight); - buffer.put(BodySize); - buffer.put(Properties.PropertyFlags); + buffer.Put(ClassId); + buffer.Put(Weight); + buffer.Put(BodySize); + buffer.Put(Properties.PropertyFlags); Properties.WritePropertyListPayload(buffer); } public void PopulateFromBuffer(ByteBuffer buffer, uint size) { - ClassId = buffer.GetUnsignedShort(); - Weight = buffer.GetUnsignedShort(); - BodySize = buffer.GetUnsignedLong(); - ushort propertyFlags = buffer.GetUnsignedShort(); + ClassId = buffer.GetUInt16(); + Weight = buffer.GetUInt16(); + BodySize = buffer.GetUInt64(); + ushort propertyFlags = buffer.GetUInt16(); ContentHeaderPropertiesFactory factory = ContentHeaderPropertiesFactory.GetInstance(); Properties = factory.CreateContentHeaderProperties(ClassId, propertyFlags, buffer); } diff --git a/qpid/dotnet/Qpid.Common/Framing/EncodingUtils.cs b/qpid/dotnet/Qpid.Common/Framing/EncodingUtils.cs index 564c9d87ef..6dc973a672 100644 --- a/qpid/dotnet/Qpid.Common/Framing/EncodingUtils.cs +++ b/qpid/dotnet/Qpid.Common/Framing/EncodingUtils.cs @@ -19,6 +19,7 @@ * */ using System; +using System.Globalization; using System.Text; using Qpid.Buffer; @@ -52,13 +53,13 @@ namespace Qpid.Framing encodedString = DEFAULT_ENCODER.GetBytes(s); } // TODO: check length fits in an unsigned byte - buffer.put((byte)encodedString.Length); - buffer.put(encodedString); + buffer.Put((byte)encodedString.Length); + buffer.Put(encodedString); } else { // really writing out unsigned byte - buffer.put((byte)0); + buffer.Put((byte)0); } } @@ -103,14 +104,14 @@ namespace Qpid.Framing } public static string ReadLongString(ByteBuffer buffer, Encoding encoding) { - uint length = buffer.getUnsignedInt(); + uint length = buffer.GetUInt32(); if ( length == 0 ) { return null; } else { byte[] data = new byte[length]; - buffer.get(data); + buffer.GetBytes(data); lock ( encoding ) { return encoding.GetString(data); @@ -132,14 +133,13 @@ namespace Qpid.Framing { lock ( encoding ) { - byte[] encodedString = null; - encodedString = encoding.GetBytes(s); - buffer.put((uint)encodedString.Length); - buffer.put(encodedString); + byte[] encodedString = encoding.GetBytes(s); + buffer.Put((uint)encodedString.Length); + buffer.Put(encodedString); } } else { - buffer.put((uint)0); + buffer.Put((uint)0); } } @@ -156,14 +156,14 @@ namespace Qpid.Framing } public static byte[] ReadLongstr(ByteBuffer buffer) { - uint length = buffer.getUnsignedInt(); + uint length = buffer.GetUInt32(); if ( length == 0 ) { return null; } else { byte[] result = new byte[length]; - buffer.get(result); + buffer.GetBytes(result); return result; } } @@ -171,18 +171,18 @@ namespace Qpid.Framing { if ( data != null ) { - buffer.put((uint)data.Length); - buffer.put(data); + buffer.Put((uint)data.Length); + buffer.Put(data); } else { - buffer.put((uint)0); + buffer.Put((uint)0); } } // BOOLEANS public static bool[] ReadBooleans(ByteBuffer buffer) { - byte packedValue = buffer.get(); + byte packedValue = buffer.GetByte(); bool[] result = new bool[8]; for ( int i = 0; i < 8; i++ ) @@ -202,7 +202,7 @@ namespace Qpid.Framing } } - buffer.put(packedValue); + buffer.Put(packedValue); } // FIELD TABLES @@ -226,7 +226,7 @@ namespace Qpid.Framing /// <exception cref="AMQFrameDecodingException">if the buffer does not contain a decodable field table</exception> public static FieldTable ReadFieldTable(ByteBuffer buffer) { - uint length = buffer.GetUnsignedInt(); + uint length = buffer.GetUInt32(); if ( length == 0 ) { return null; @@ -242,7 +242,7 @@ namespace Qpid.Framing table.WriteToBuffer(buffer); } else { - buffer.put((uint)0); + buffer.Put((uint)0); } } @@ -255,14 +255,14 @@ namespace Qpid.Framing /// <exception cref="AMQFrameDecodingException">if the buffer does not contain a decodable short string</exception> public static string ReadShortString(ByteBuffer buffer) { - byte length = buffer.get(); + byte length = buffer.GetByte(); if ( length == 0 ) { return null; } else { byte[] data = new byte[length]; - buffer.get(data); + buffer.GetBytes(data); lock ( DEFAULT_ENCODER ) { @@ -280,12 +280,12 @@ namespace Qpid.Framing } public static bool ReadBoolean(ByteBuffer buffer) { - byte packedValue = buffer.get(); + byte packedValue = buffer.GetByte(); return (packedValue == 1); } public static void WriteBoolean(ByteBuffer buffer, bool value) { - buffer.put((byte)(value ? 1 : 0)); + buffer.Put((byte)(value ? 1 : 0)); } @@ -296,11 +296,11 @@ namespace Qpid.Framing } public static char ReadChar(ByteBuffer buffer) { - return (char)buffer.get(); + return (char)buffer.GetByte(); } public static void WriteChar(ByteBuffer buffer, char value) { - buffer.put((byte)value); + buffer.Put((byte)value); } // BYTE @@ -310,11 +310,11 @@ namespace Qpid.Framing } public static byte ReadByte(ByteBuffer buffer) { - return buffer.get(); + return buffer.GetByte(); } public static void WriteByte(ByteBuffer buffer, byte value) { - buffer.put(value); + buffer.Put(value); } // SBYTE @@ -324,11 +324,11 @@ namespace Qpid.Framing } public static sbyte ReadSByte(ByteBuffer buffer) { - return (sbyte)buffer.get(); + return buffer.GetSByte(); } public static void WriteSByte(ByteBuffer buffer, sbyte value) { - buffer.put((byte)value); + buffer.Put(value); } // INT16 @@ -339,11 +339,11 @@ namespace Qpid.Framing public static short ReadShort(ByteBuffer buffer) { - return buffer.getShort(); + return buffer.GetInt16(); } public static void WriteShort(ByteBuffer buffer, short value) { - buffer.putShort(value); + buffer.Put(value); } // UINT16 @@ -354,11 +354,11 @@ namespace Qpid.Framing public static ushort ReadUnsignedShort(ByteBuffer buffer) { - return buffer.GetUnsignedShort(); + return buffer.GetUInt16(); } public static void WriteUnsignedShort(ByteBuffer buffer, ushort value) { - buffer.put(value); + buffer.Put(value); } @@ -369,11 +369,11 @@ namespace Qpid.Framing } public static int ReadInteger(ByteBuffer buffer) { - return buffer.getInt(); + return buffer.GetInt32(); } public static void WriteInteger(ByteBuffer buffer, int value) { - buffer.putInt(value); + buffer.Put(value); } // UINT32 @@ -383,11 +383,11 @@ namespace Qpid.Framing } public static void WriteUnsignedInteger(ByteBuffer buffer, uint value) { - buffer.put(value); + buffer.Put(value); } public static uint ReadUnsignedInteger(ByteBuffer buffer) { - return buffer.getUnsignedInt(); + return buffer.GetUInt32(); } // INT64 @@ -397,11 +397,11 @@ namespace Qpid.Framing } public static ulong ReadUnsignedLong(ByteBuffer buffer) { - return buffer.GetUnsignedLong(); + return buffer.GetUInt64(); } public static void WriteUnsignedLong(ByteBuffer buffer, ulong value) { - buffer.put(value); + buffer.Put(value); } // UINT64 @@ -411,11 +411,11 @@ namespace Qpid.Framing } public static long ReadLong(ByteBuffer buffer) { - return buffer.getLong(); + return buffer.GetInt64(); } public static void WriteLong(ByteBuffer buffer, long value) { - buffer.putLong(value); + buffer.Put(value); } // FLOAT @@ -425,11 +425,11 @@ namespace Qpid.Framing } public static void WriteFloat(ByteBuffer buffer, float value) { - buffer.putFloat(value); + buffer.Put(value); } public static float ReadFloat(ByteBuffer buffer) { - return buffer.getFloat(); + return buffer.GetFloat(); } // DOUBLE @@ -439,11 +439,20 @@ namespace Qpid.Framing } public static void WriteDouble(ByteBuffer buffer, double value) { - buffer.putDouble(value); + buffer.Put(value); } public static double ReadDouble(ByteBuffer buffer) { - return buffer.getDouble(); + return buffer.GetDouble(); + } + + // OTHER + public static long ReadLongAsShortString(ByteBuffer buffer) + { + string value = ReadShortString(buffer); + if ( value == null || value.Length == 0 ) + return 0L; + return Convert.ToInt64(value, CultureInfo.InvariantCulture); } } diff --git a/qpid/dotnet/Qpid.Common/Framing/FieldTable.cs b/qpid/dotnet/Qpid.Common/Framing/FieldTable.cs index b977bef0ba..fe83fff721 100644 --- a/qpid/dotnet/Qpid.Common/Framing/FieldTable.cs +++ b/qpid/dotnet/Qpid.Common/Framing/FieldTable.cs @@ -50,10 +50,10 @@ namespace Qpid.Framing /// <exception cref="AMQFrameDecodingException">if there is an error decoding the table</exception> public FieldTable(ByteBuffer buffer, uint length) : this() { - _encodedForm = buffer.slice(); - _encodedForm.limit((int)length); + _encodedForm = buffer.Slice(); + _encodedForm.Limit = (int)length; _encodedSize = length; - buffer.skip((int)length); + buffer.Skip((int)length); } /// <summary> @@ -312,6 +312,7 @@ namespace Qpid.Framing /// <returns>The enumerator object</returns> public IEnumerator GetEnumerator() { + InitMapIfNecessary(); return _properties.GetEnumerator(); } @@ -322,6 +323,7 @@ namespace Qpid.Framing /// <returns>True if the property exists</returns> public bool Contains(string s) { + InitMapIfNecessary(); return _properties.Contains(s); } @@ -332,6 +334,7 @@ namespace Qpid.Framing /// <returns>The internal dictionary</returns> public IDictionary AsDictionary() { + InitMapIfNecessary(); return _properties; } @@ -381,11 +384,11 @@ namespace Qpid.Framing /// <returns>An array of bytes</returns> public byte[] GetDataAsBytes() { - ByteBuffer buffer = ByteBuffer.allocate((int)_encodedSize); + ByteBuffer buffer = ByteBuffer.Allocate((int)_encodedSize); WritePayload(buffer); byte[] result = new byte[_encodedSize]; - buffer.flip(); - buffer.get(result); + buffer.Flip(); + buffer.GetBytes(result); //buffer.Release(); return result; } @@ -527,7 +530,7 @@ namespace Qpid.Framing bool trace = _log.IsDebugEnabled; if ( length > 0 ) { - int expectedRemaining = buffer.remaining() - (int)length; + int expectedRemaining = buffer.Remaining - (int)length; _properties = new LinkedHashtable(); do @@ -540,7 +543,7 @@ namespace Qpid.Framing } _properties.Add(key, value); - } while ( buffer.remaining() > expectedRemaining ); + } while ( buffer.Remaining > expectedRemaining ); _encodedSize = length; } if ( trace ) @@ -595,7 +598,7 @@ namespace Qpid.Framing { if ( _encodedForm != null ) { - buffer.put(_encodedForm); + buffer.Put(_encodedForm); } else if ( _properties != null ) { foreach ( DictionaryEntry de in _properties ) @@ -609,8 +612,8 @@ namespace Qpid.Framing _log.Debug("Writing Property:" + key + " Type:" + value.Type + " Value:" + value.Value); - _log.Debug("Buffer Position:" + buffer.position() + - " Remaining:" + buffer.remaining()); + _log.Debug("Buffer Position:" + buffer.Position + + " Remaining:" + buffer.Remaining); } //Write the actual parameter name EncodingUtils.WriteShortStringBytes(buffer, key); @@ -623,8 +626,8 @@ namespace Qpid.Framing _log.Debug("Writing Property:" + key + " Type:" + value.Type + " Value:" + value.Value); - _log.Debug("Buffer Position:" + buffer.position() + - " Remaining:" + buffer.remaining()); + _log.Debug("Buffer Position:" + buffer.Position + + " Remaining:" + buffer.Remaining); } } } diff --git a/qpid/dotnet/Qpid.Common/Framing/HeartbeatBody.cs b/qpid/dotnet/Qpid.Common/Framing/HeartbeatBody.cs index 07f9f345bb..3fdaa7e850 100644 --- a/qpid/dotnet/Qpid.Common/Framing/HeartbeatBody.cs +++ b/qpid/dotnet/Qpid.Common/Framing/HeartbeatBody.cs @@ -52,7 +52,7 @@ namespace Qpid.Framing if (size > 0) { //allow other implementations to have a payload, but ignore it: - buffer.skip((int) size); + buffer.Skip((int) size); } } diff --git a/qpid/dotnet/Qpid.Common/Framing/ProtocolInitiation.cs b/qpid/dotnet/Qpid.Common/Framing/ProtocolInitiation.cs index 886fbcee09..280242513c 100644 --- a/qpid/dotnet/Qpid.Common/Framing/ProtocolInitiation.cs +++ b/qpid/dotnet/Qpid.Common/Framing/ProtocolInitiation.cs @@ -72,12 +72,12 @@ namespace Qpid.Framing { foreach (char c in Header) { - buffer.put((byte) c); + buffer.Put((byte) c); } - buffer.put(ProtocolClass); - buffer.put(ProtocolInstance); - buffer.put(ProtocolMajor); - buffer.put(ProtocolMinor); + buffer.Put(ProtocolClass); + buffer.Put(ProtocolInstance); + buffer.Put(ProtocolMajor); + buffer.Put(ProtocolMinor); } /// <summary> @@ -99,7 +99,7 @@ namespace Qpid.Framing { return MessageDecoderResult.NOT_OK; } - if (inbuf.remaining() < 8) + if (inbuf.Remaining < 8) { return MessageDecoderResult.NEED_DATA; } @@ -108,7 +108,7 @@ namespace Qpid.Framing char[] expected = new char[]{'A', 'M', 'Q', 'P'}; for (int i = 0; i < 4; i++) { - if (((char) inbuf.get()) != expected[i]) + if (((char) inbuf.GetByte()) != expected[i]) { return MessageDecoderResult.NOT_OK; } @@ -120,21 +120,19 @@ namespace Qpid.Framing /// <summary> /// Decodes the specified session. /// </summary> - /// <param name="session">The session.</param> /// <param name="inbuf">The inbuf.</param> - /// <param name="outbuf">The outbuf.</param> + /// <param name="output">The protocol output.</param> /// <returns></returns> - /// <exception cref="ProtocolViolationException">thrown if the frame violates the protocol</exception> public MessageDecoderResult Decode(ByteBuffer inbuf, IProtocolDecoderOutput output) { byte[] header = new byte[4]; - inbuf.get(header); + inbuf.GetBytes(header); ProtocolInitiation pi = new ProtocolInitiation(); pi.Header = new char[]{'A','M','Q','P'}; - pi.ProtocolClass = inbuf.get(); - pi.ProtocolInstance = inbuf.get(); - pi.ProtocolMajor = inbuf.get(); - pi.ProtocolMinor = inbuf.get(); + pi.ProtocolClass = inbuf.GetByte(); + pi.ProtocolInstance = inbuf.GetByte(); + pi.ProtocolMajor = inbuf.GetByte(); + pi.ProtocolMinor = inbuf.GetByte(); output.Write(pi); return MessageDecoderResult.OK; } diff --git a/qpid/dotnet/Qpid.Common/Qpid.Common.csproj b/qpid/dotnet/Qpid.Common/Qpid.Common.csproj index 626a889e0a..dccadd4667 100644 --- a/qpid/dotnet/Qpid.Common/Qpid.Common.csproj +++ b/qpid/dotnet/Qpid.Common/Qpid.Common.csproj @@ -89,6 +89,7 @@ <Compile Include="generated\BasicQosBody.cs" />
<Compile Include="generated\BasicQosOkBody.cs" />
<Compile Include="generated\BasicRecoverBody.cs" />
+ <Compile Include="generated\BasicRecoverOkBody.cs" />
<Compile Include="generated\BasicRejectBody.cs" />
<Compile Include="generated\BasicReturnBody.cs" />
<Compile Include="generated\ChannelAlertBody.cs" />
diff --git a/qpid/dotnet/Qpid.Common/stylesheets/utils.xsl b/qpid/dotnet/Qpid.Common/stylesheets/utils.xsl index 38405ad694..422b757b5c 100644 --- a/qpid/dotnet/Qpid.Common/stylesheets/utils.xsl +++ b/qpid/dotnet/Qpid.Common/stylesheets/utils.xsl @@ -67,19 +67,19 @@ <xsl:param name="f"/> <xsl:choose> <xsl:when test="$f/@type='char'"> - <xsl:value-of select="concat('buffer.put(', $f/@name, ')')"/> + <xsl:value-of select="concat('buffer.Put(', $f/@name, ')')"/> </xsl:when> <xsl:when test="$f/@type='octet'"> - <xsl:value-of select="concat('buffer.put(', $f/@name, ')')"/> + <xsl:value-of select="concat('buffer.Put(', $f/@name, ')')"/> </xsl:when> <xsl:when test="$f/@type='short'"> - <xsl:value-of select="concat('buffer.put(', $f/@name, ')')"/> + <xsl:value-of select="concat('buffer.Put(', $f/@name, ')')"/> </xsl:when> <xsl:when test="$f/@type='long'"> - <xsl:value-of select="concat('buffer.put(', $f/@name, ')')"/> + <xsl:value-of select="concat('buffer.Put(', $f/@name, ')')"/> </xsl:when> <xsl:when test="$f/@type='longlong'"> - <xsl:value-of select="concat('buffer.put(', $f/@name, ')')"/> + <xsl:value-of select="concat('buffer.Put(', $f/@name, ')')"/> </xsl:when> <xsl:when test="$f/@type='shortstr'"> <xsl:value-of select="concat('EncodingUtils.WriteShortStringBytes(buffer, ', $f/@name, ')')"/> @@ -108,16 +108,16 @@ <xsl:value-of select="concat($f/@name, ' = buffer.GetChar()')"/> </xsl:when> <xsl:when test="$f/@type='octet'"> - <xsl:value-of select="concat($f/@name, ' = buffer.get()')"/> + <xsl:value-of select="concat($f/@name, ' = buffer.GetByte()')"/> </xsl:when> <xsl:when test="$f/@type='short'"> - <xsl:value-of select="concat($f/@name, ' = buffer.GetUnsignedShort()')"/> + <xsl:value-of select="concat($f/@name, ' = buffer.GetUInt16()')"/> </xsl:when> <xsl:when test="$f/@type='long'"> - <xsl:value-of select="concat($f/@name, ' = buffer.GetUnsignedInt()')"/> + <xsl:value-of select="concat($f/@name, ' = buffer.GetUInt32()')"/> </xsl:when> <xsl:when test="$f/@type='longlong'"> - <xsl:value-of select="concat($f/@name, ' = buffer.GetUnsignedLong()')"/> + <xsl:value-of select="concat($f/@name, ' = buffer.GetUInt64()')"/> </xsl:when> <xsl:when test="$f/@type='shortstr'"> <xsl:value-of select="concat($f/@name, ' = EncodingUtils.ReadShortString(buffer)')"/> |