Class Encoder
Encodes or decodes AMQP types.
Inheritance
Inherited Members
Namespace: Amqp.Types
Assembly: Amqp.Net.dll
Syntax
public static class Encoder
Methods
AddKnownDescribed(Descriptor, CreateDescribed)
Adds a factory for a custom described type, usually for decoding.
Declaration
public static void AddKnownDescribed(Descriptor descriptor, CreateDescribed ctor)
Parameters
Type | Name | Description |
---|---|---|
Descriptor | descriptor | The descriptor of the type. |
CreateDescribed | ctor | The delegate to invoke to create the object. |
DateTimeToTimestamp(DateTime)
Converts a DateTime value to AMQP timestamp (milliseconds from Unix epoch)
Declaration
public static long DateTimeToTimestamp(DateTime dateTime)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | dateTime | The DateTime value to convert. |
Returns
Type | Description |
---|---|
System.Int64 |
ReadArray(ByteBuffer, Byte)
Reads an array value from a buffer.
Declaration
public static Array ReadArray(ByteBuffer buffer, byte formatCode)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to read. |
System.Byte | formatCode | The format code of the value. |
Returns
Type | Description |
---|---|
System.Array |
ReadBinary(ByteBuffer, Byte)
Reads a binary value from a buffer.
Declaration
public static byte[] ReadBinary(ByteBuffer buffer, byte formatCode)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to read. |
System.Byte | formatCode | The format code of the value. |
Returns
Type | Description |
---|---|
System.Byte[] |
ReadBoolean(ByteBuffer, Byte)
Reads a boolean value from a buffer.
Declaration
public static bool ReadBoolean(ByteBuffer buffer, byte formatCode)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to read. |
System.Byte | formatCode | The format code of the value. |
Returns
Type | Description |
---|---|
System.Boolean |
ReadByte(ByteBuffer, Byte)
Reads a signed byte from a buffer.
Declaration
public static sbyte ReadByte(ByteBuffer buffer, byte formatCode)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to read. |
System.Byte | formatCode | The format code of the value. |
Returns
Type | Description |
---|---|
System.SByte |
ReadChar(ByteBuffer, Byte)
Reads a char value from a buffer.
Declaration
public static char ReadChar(ByteBuffer buffer, byte formatCode)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to read. |
System.Byte | formatCode | The format code of the value. |
Returns
Type | Description |
---|---|
System.Char |
ReadDecimal(ByteBuffer, Byte)
Reads a Decimal value from a buffer.
Declaration
public static Decimal ReadDecimal(ByteBuffer buffer, byte formatCode)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to read. |
System.Byte | formatCode | The format code of the value. |
Returns
Type | Description |
---|---|
Decimal |
ReadDescribed(ByteBuffer, Byte)
Reads a described value from a buffer.
Declaration
public static object ReadDescribed(ByteBuffer buffer, byte formatCode)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to read. |
System.Byte | formatCode | The format code of the value. |
Returns
Type | Description |
---|---|
System.Object |
ReadDouble(ByteBuffer, Byte)
Reads a 64-bit floating-point value from a buffer.
Declaration
public static double ReadDouble(ByteBuffer buffer, byte formatCode)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to read. |
System.Byte | formatCode | The format code of the value. |
Returns
Type | Description |
---|---|
System.Double |
ReadFields(ByteBuffer, Byte)
Reads a Fields map value from a buffer.
Declaration
public static Fields ReadFields(ByteBuffer buffer, byte formatCode)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to read. |
System.Byte | formatCode | The format code of the value. |
Returns
Type | Description |
---|---|
Fields |
ReadFloat(ByteBuffer, Byte)
Reads a 32-bit floating-point value from a buffer.
Declaration
public static float ReadFloat(ByteBuffer buffer, byte formatCode)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to read. |
System.Byte | formatCode | The format code of the value. |
Returns
Type | Description |
---|---|
System.Single |
ReadFormatCode(ByteBuffer)
Reads the format code from the buffer.
Declaration
public static byte ReadFormatCode(ByteBuffer buffer)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to read. |
Returns
Type | Description |
---|---|
System.Byte | A byte value for the format code. |
ReadInt(ByteBuffer, Byte)
Reads a signed 32-bit integer from a buffer.
Declaration
public static int ReadInt(ByteBuffer buffer, byte formatCode)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to read. |
System.Byte | formatCode | The format code of the value. |
Returns
Type | Description |
---|---|
System.Int32 |
ReadList(ByteBuffer, Byte)
Reads a list value from a buffer.
Declaration
public static List ReadList(ByteBuffer buffer, byte formatCode)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to read. |
System.Byte | formatCode | The format code of the value. |
Returns
Type | Description |
---|---|
List |
ReadLong(ByteBuffer, Byte)
Reads a signed 64-bit integer from a buffer.
Declaration
public static long ReadLong(ByteBuffer buffer, byte formatCode)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to read. |
System.Byte | formatCode | The format code of the value. |
Returns
Type | Description |
---|---|
System.Int64 |
ReadMap(ByteBuffer, Byte)
Reads a map value from a buffer.
Declaration
public static Map ReadMap(ByteBuffer buffer, byte formatCode)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to read. |
System.Byte | formatCode | The format code of the value. |
Returns
Type | Description |
---|---|
Map |
ReadObject(ByteBuffer)
Reads an object from a buffer.
Declaration
public static object ReadObject(ByteBuffer buffer)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to read. |
Returns
Type | Description |
---|---|
System.Object |
ReadObject(ByteBuffer, Byte)
Reads an object from a buffer.
Declaration
public static object ReadObject(ByteBuffer buffer, byte formatCode)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to read. |
System.Byte | formatCode | The format code of the value. |
Returns
Type | Description |
---|---|
System.Object |
ReadShort(ByteBuffer, Byte)
Reads a signed 16-bit integer from a buffer.
Declaration
public static short ReadShort(ByteBuffer buffer, byte formatCode)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to read. |
System.Byte | formatCode | The format code of the value. |
Returns
Type | Description |
---|---|
System.Int16 |
ReadString(ByteBuffer, Byte)
Reads a string value from a buffer.
Declaration
public static string ReadString(ByteBuffer buffer, byte formatCode)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to read. |
System.Byte | formatCode | The format code of the value. |
Returns
Type | Description |
---|---|
System.String |
ReadSymbol(ByteBuffer, Byte)
Reads a symbol value from a buffer.
Declaration
public static Symbol ReadSymbol(ByteBuffer buffer, byte formatCode)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to read. |
System.Byte | formatCode | The format code of the value. |
Returns
Type | Description |
---|---|
Symbol |
ReadTimestamp(ByteBuffer, Byte)
Reads a timestamp value from a buffer.
Declaration
public static DateTime ReadTimestamp(ByteBuffer buffer, byte formatCode)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to read. |
System.Byte | formatCode | The format code of the value. |
Returns
Type | Description |
---|---|
System.DateTime |
ReadUByte(ByteBuffer, Byte)
Reads an unsigned byte value from a buffer.
Declaration
public static byte ReadUByte(ByteBuffer buffer, byte formatCode)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to read. |
System.Byte | formatCode | The format code of the value. |
Returns
Type | Description |
---|---|
System.Byte |
ReadUInt(ByteBuffer, Byte)
Reads an unsigned 32-bit integer from a buffer.
Declaration
public static uint ReadUInt(ByteBuffer buffer, byte formatCode)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to read. |
System.Byte | formatCode | The format code of the value. |
Returns
Type | Description |
---|---|
System.UInt32 |
ReadULong(ByteBuffer, Byte)
Reads an unsigned 64-bit integer from a buffer.
Declaration
public static ulong ReadULong(ByteBuffer buffer, byte formatCode)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to read. |
System.Byte | formatCode | The format code of the value. |
Returns
Type | Description |
---|---|
System.UInt64 |
ReadUShort(ByteBuffer, Byte)
Reads an unsigned 16-bit integer from a buffer.
Declaration
public static ushort ReadUShort(ByteBuffer buffer, byte formatCode)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to read. |
System.Byte | formatCode | The format code of the value. |
Returns
Type | Description |
---|---|
System.UInt16 |
ReadUuid(ByteBuffer, Byte)
Reads a uuid value from a buffer.
Declaration
public static Guid ReadUuid(ByteBuffer buffer, byte formatCode)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to read. |
System.Byte | formatCode | The format code of the value. |
Returns
Type | Description |
---|---|
System.Guid |
TimestampToDateTime(Int64)
Converts an AMQP timestamp ((milliseconds from Unix epoch)) to a DateTime.
Declaration
public static DateTime TimestampToDateTime(long timestamp)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | timestamp | The AMQP timestamp to convert. |
Returns
Type | Description |
---|---|
System.DateTime |
TryGetCodec(Type, out Encode, out Decode)
Gets the encode and decode delegates for a given type.
Declaration
public static bool TryGetCodec(Type type, out Encode encoder, out Decode decoder)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type | The type used to look for the encode and decode delegates. |
Encode | encoder | The encode delegate for the given type. |
Decode | decoder | The decode delegate for the given type. |
Returns
Type | Description |
---|---|
System.Boolean | A boolean value indicating if the delegates are found. |
WriteArray(ByteBuffer, Array)
Writes an array value to a buffer.
Declaration
public static void WriteArray(ByteBuffer buffer, Array value)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to write. |
System.Array | value | The array value. |
WriteBinary(ByteBuffer, Byte[], Boolean)
Writes a binary value to a buffer.
Declaration
public static void WriteBinary(ByteBuffer buffer, byte[] value, bool smallEncoding)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to write. |
System.Byte[] | value | The binary value. |
System.Boolean | smallEncoding | if true, try using small encoding if possible. |
WriteBoolean(ByteBuffer, Boolean, Boolean)
Writes a boolean value to a buffer.
Declaration
public static void WriteBoolean(ByteBuffer buffer, bool value, bool smallEncoding)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to write. |
System.Boolean | value | The boolean value. |
System.Boolean | smallEncoding | if true, try using small encoding if possible. |
WriteByte(ByteBuffer, SByte)
Writes a signed byte value to a buffer.
Declaration
public static void WriteByte(ByteBuffer buffer, sbyte value)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to write. |
System.SByte | value | The signed byte value. |
WriteChar(ByteBuffer, Char)
Writes a char value to a buffer.
Declaration
public static void WriteChar(ByteBuffer buffer, char value)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to write. |
System.Char | value | The char value. |
WriteDecimal(ByteBuffer, Decimal)
Writes a Decimal value to a buffer.
Declaration
public static void WriteDecimal(ByteBuffer buffer, Decimal value)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to write. |
Decimal | value | The Decimal value. |
WriteDouble(ByteBuffer, Double)
Writes a 64-bit floating-point value to a buffer.
Declaration
public static void WriteDouble(ByteBuffer buffer, double value)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to write. |
System.Double | value | The 64-bit floating-point value. |
WriteFloat(ByteBuffer, Single)
Writes a 32-bit floating-point value to a buffer.
Declaration
public static void WriteFloat(ByteBuffer buffer, float value)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to write. |
System.Single | value | The 32-bit floating-point value. |
WriteInt(ByteBuffer, Int32, Boolean)
Writes a signed 32-bit integer value to a buffer.
Declaration
public static void WriteInt(ByteBuffer buffer, int value, bool smallEncoding)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to write. |
System.Int32 | value | The signed 32-bit integer value. |
System.Boolean | smallEncoding | if true, try using small encoding if possible. |
WriteList(ByteBuffer, IList, Boolean)
Writes a list value to a buffer.
Declaration
public static void WriteList(ByteBuffer buffer, IList value, bool smallEncoding)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to write. |
System.Collections.IList | value | The list value. |
System.Boolean | smallEncoding | if true, try using small encoding if possible. |
WriteLong(ByteBuffer, Int64, Boolean)
Writes a signed 64-bit integer value to a buffer.
Declaration
public static void WriteLong(ByteBuffer buffer, long value, bool smallEncoding)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to write. |
System.Int64 | value | The signed 64-bit integer value. |
System.Boolean | smallEncoding | if true, try using small encoding if possible. |
WriteMap(ByteBuffer, Map, Boolean)
Writes a map value to a buffer.
Declaration
public static void WriteMap(ByteBuffer buffer, Map value, bool smallEncoding)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to write. |
Map | value | The map value. |
System.Boolean | smallEncoding | if true, try using small encoding if possible. |
WriteObject(ByteBuffer, Object, Boolean)
Writes an AMQP object to a buffer.
Declaration
public static void WriteObject(ByteBuffer buffer, object value, bool smallEncoding = true)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to write. |
System.Object | value | The AMQP value. |
System.Boolean | smallEncoding | if true, try using small encoding if possible. |
WriteShort(ByteBuffer, Int16)
Writes a signed 16-bit integer value to a buffer.
Declaration
public static void WriteShort(ByteBuffer buffer, short value)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to write. |
System.Int16 | value | The signed 16-bit integer value. |
WriteString(ByteBuffer, String, Boolean)
Writes a string value to a buffer.
Declaration
public static void WriteString(ByteBuffer buffer, string value, bool smallEncoding)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to write. |
System.String | value | The string value. |
System.Boolean | smallEncoding | if true, try using small encoding if possible. |
WriteSymbol(ByteBuffer, Symbol, Boolean)
Writes a symbol value to a buffer.
Declaration
public static void WriteSymbol(ByteBuffer buffer, Symbol value, bool smallEncoding)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to write. |
Symbol | value | The symbol value. |
System.Boolean | smallEncoding | if true, try using small encoding if possible. |
WriteTimestamp(ByteBuffer, DateTime)
Writes a timestamp value to a buffer.
Declaration
public static void WriteTimestamp(ByteBuffer buffer, DateTime value)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to write. |
System.DateTime | value | The timestamp value which is the milliseconds since UNIX epoch. |
WriteUByte(ByteBuffer, Byte)
Writes an unsigned byte value to a buffer.
Declaration
public static void WriteUByte(ByteBuffer buffer, byte value)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to write. |
System.Byte | value | The unsigned byte value. |
WriteUInt(ByteBuffer, UInt32, Boolean)
Writes an unsigned 32-bit integer value to a buffer.
Declaration
public static void WriteUInt(ByteBuffer buffer, uint value, bool smallEncoding)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to write. |
System.UInt32 | value | The unsigned 32-bit integer value. |
System.Boolean | smallEncoding | if true, try using small encoding if possible. |
WriteULong(ByteBuffer, UInt64, Boolean)
Writes an unsigned 64-bit integer value to a buffer.
Declaration
public static void WriteULong(ByteBuffer buffer, ulong value, bool smallEncoding)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to write. |
System.UInt64 | value | The unsigned 64-bit integer value. |
System.Boolean | smallEncoding | if true, try using small encoding if possible. |
WriteUShort(ByteBuffer, UInt16)
Writes an unsigned 16-bit integer value to a buffer.
Declaration
public static void WriteUShort(ByteBuffer buffer, ushort value)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to write. |
System.UInt16 | value | The unsigned 16-bit integer value. |
WriteUuid(ByteBuffer, Guid)
Writes a uuid value to a buffer.
Declaration
public static void WriteUuid(ByteBuffer buffer, Guid value)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | buffer | The buffer to write. |
System.Guid | value | The uuid value. |