Class Element
A Matroska element.
Inheritance
Namespace: FM.LiveSwitch.Matroska
Assembly: FM.LiveSwitch.dll
Syntax
public abstract class Element : object
Properties
Id
Gets the EBML ID.
Declaration
public abstract byte[] Id { get; }
Property Value
Type | Description |
---|---|
System.Byte[] |
Length
Gets the total length of the element (including ID/size field), set after calling GetBytes().
Declaration
public int Length { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Size
Gets the size of the element (excluding ID/size field), set after calling GetBytes().
Declaration
public int Size { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
SizeLength
Gets or sets the length of the size field, in bytes. Defaults to zero (variable size).
Declaration
public int SizeLength { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
WriteDefaultValues
Gets or sets whether to include default values when serializing.
Declaration
public bool WriteDefaultValues { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
Compare(Byte[], Byte[])
Compares two byte arrays for equality.
Declaration
public static bool Compare(byte[] bytes1, byte[] bytes2)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | bytes1 | The first byte array. |
System.Byte[] | bytes2 | The second byte array. |
Returns
Type | Description |
---|---|
System.Boolean |
GetBytes()
Serializes to a byte array.
Declaration
public byte[] GetBytes()
Returns
Type | Description |
---|---|
System.Byte[] |
GetInnerBytes()
Gets the inner bytes.
Declaration
protected abstract byte[] GetInnerBytes()
Returns
Type | Description |
---|---|
System.Byte[] |
ReadBool(Byte[])
Reads a boolean element from the stream.
Declaration
public static bool ReadBool(byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | The value. |
Returns
Type | Description |
---|---|
System.Boolean |
ReadDate(Byte[])
Reads a date string element from the stream.
Declaration
public static DateTime ReadDate(byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | The value. |
Returns
Type | Description |
---|---|
DateTime |
ReadDouble(Byte[])
Reads a double element from the stream.
Declaration
public static double ReadDouble(byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | The value. |
Returns
Type | Description |
---|---|
System.Double |
ReadFloat(Byte[])
Reads a float element from the stream.
Declaration
public static float ReadFloat(byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | The value. |
Returns
Type | Description |
---|---|
System.Single |
ReadGuid(Byte[])
Reads a GUID element from the stream.
Declaration
public static Guid ReadGuid(byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | The value. |
Returns
Type | Description |
---|---|
Guid |
ReadId(Byte[], Int32, out Int32)
Reads a binary ID from the stream.
Declaration
public static byte[] ReadId(byte[] bytes, int offset, out int offsetPlus)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | bytes | The byte array. |
System.Int32 | offset | The offset into the byte array. |
System.Int32 | offsetPlus | The offset plus the amount read. |
Returns
Type | Description |
---|---|
System.Byte[] |
ReadSignedInteger(Byte[])
Reads a signed integer element from the byte array.
Declaration
public static long ReadSignedInteger(byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | The value. |
Returns
Type | Description |
---|---|
System.Int64 |
ReadString(Byte[])
Reads an ASCII string element from the stream.
Declaration
public static string ReadString(byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | The value. |
Returns
Type | Description |
---|---|
System.String |
ReadUnsignedInteger(Byte[])
Reads an unsigned integer element from the byte array.
Declaration
public static long ReadUnsignedInteger(byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | The value. |
Returns
Type | Description |
---|---|
System.Int64 |
ReadUtf8(Byte[])
Reads a UTF-8 string element from the stream.
Declaration
public static string ReadUtf8(byte[] value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | The value. |
Returns
Type | Description |
---|---|
System.String |
ReadValue(Byte[], Int32, out Int32)
Reads a binary value from the stream.
Declaration
public static byte[] ReadValue(byte[] bytes, int offset, out int offsetPlus)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | bytes | The byte array. |
System.Int32 | offset | The offset into the byte array. |
System.Int32 | offsetPlus | The offset plus the amount read. |
Returns
Type | Description |
---|---|
System.Byte[] |
ReadVariableInteger(Byte[], Int32, out Int32)
Reads a variable integer ("vint") from the byte array.
Declaration
public static long ReadVariableInteger(byte[] bytes, int offset, out int offsetPlus)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | bytes | The byte array. |
System.Int32 | offset | The offset into the byte array. |
System.Int32 | offsetPlus | The offset plus the amount read. |
Returns
Type | Description |
---|---|
System.Int64 |
SerializeVariableInteger(Int64)
Serializes a variable integer.
Declaration
public static byte[] SerializeVariableInteger(long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The value. |
Returns
Type | Description |
---|---|
System.Byte[] |
SerializeVariableInteger(Int64, Int32)
Serializes a variable integer using a fixed length.
Declaration
public static byte[] SerializeVariableInteger(long value, int length)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The value. |
System.Int32 | length | The length to use. |
Returns
Type | Description |
---|---|
System.Byte[] |
Write(Byte[], Byte[], ByteOutputStream)
Writes a binary element to the stream.
Declaration
protected void Write(byte[] value, byte[] id, ByteOutputStream stream)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | value | The value to write. |
System.Byte[] | id | The ID of the value. |
ByteOutputStream | stream | The stream to write. |
WriteBool(Boolean, Byte[], ByteOutputStream)
Writes a boolean element to the stream.
Declaration
protected void WriteBool(bool value, byte[] id, ByteOutputStream stream)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | value | The value to write. |
System.Byte[] | id | The ID of the value. |
ByteOutputStream | stream | The stream to write. |
WriteDate(DateTime, Byte[], ByteOutputStream)
Writes a date element to the stream.
Declaration
protected void WriteDate(DateTime value, byte[] id, ByteOutputStream stream)
Parameters
Type | Name | Description |
---|---|---|
DateTime | value | The value to write. |
System.Byte[] | id | The ID of the value. |
ByteOutputStream | stream | The stream to write. |
WriteDouble(Double, Byte[], ByteOutputStream)
Writes a double element to the stream.
Declaration
protected void WriteDouble(double value, byte[] id, ByteOutputStream stream)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | The value to write. |
System.Byte[] | id | The ID of the value. |
ByteOutputStream | stream | The stream to write. |
WriteFloat(Single, Byte[], ByteOutputStream)
Writes a float element to the stream.
Declaration
protected void WriteFloat(float value, byte[] id, ByteOutputStream stream)
Parameters
Type | Name | Description |
---|---|---|
System.Single | value | The value to write. |
System.Byte[] | id | The ID of the value. |
ByteOutputStream | stream | The stream to write. |
WriteGuid(Guid, Byte[], ByteOutputStream)
Writes a GUID element to the stream.
Declaration
protected void WriteGuid(Guid value, byte[] id, ByteOutputStream stream)
Parameters
Type | Name | Description |
---|---|---|
Guid | value | The value to write. |
System.Byte[] | id | The ID of the value. |
ByteOutputStream | stream | The stream to write. |
WriteSignedInteger(Int64, Byte[], ByteOutputStream)
Writes an signed integer element to the stream.
Declaration
protected void WriteSignedInteger(long value, byte[] id, ByteOutputStream stream)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The value to write. |
System.Byte[] | id | The ID of the value. |
ByteOutputStream | stream | The stream to write. |
WriteString(String, Byte[], ByteOutputStream)
Writes an ASCII string element to the stream.
Declaration
protected void WriteString(string value, byte[] id, ByteOutputStream stream)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to write. |
System.Byte[] | id | The ID of the value. |
ByteOutputStream | stream | The stream to write. |
WriteUnsignedInteger(Int64, Byte[], ByteOutputStream)
Writes an unsigned integer element to the stream.
Declaration
protected void WriteUnsignedInteger(long value, byte[] id, ByteOutputStream stream)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The value to write. |
System.Byte[] | id | The ID of the value. |
ByteOutputStream | stream | The stream to write. |
WriteUtf8(String, Byte[], ByteOutputStream)
Writes a UTF-8 string element to the stream.
Declaration
protected void WriteUtf8(string value, byte[] id, ByteOutputStream stream)
Parameters
Type | Name | Description |
---|---|---|
System.String | value | The value to write. |
System.Byte[] | id | The ID of the value. |
ByteOutputStream | stream | The stream to write. |
WriteVariableInteger(Int64, ByteOutputStream)
Writes a variable integer ("vint") to the stream.
Declaration
protected void WriteVariableInteger(long value, ByteOutputStream stream)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The value to write. |
ByteOutputStream | stream | The stream to write. |
WriteVariableInteger(Int64, ByteOutputStream, Int32)
Writes a variable integer ("vint") to the stream using a fixed length.
Declaration
protected void WriteVariableInteger(long value, ByteOutputStream stream, int length)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | The value to write. |
ByteOutputStream | stream | The stream to write. |
System.Int32 | length | The length to use. |