Namespace: | Sirenix.Serialization |
Assembly: | Sirenix.Serialization |
public abstract class BaseDataReader : BaseDataReaderWriter, IDataReader, IDisposable
If you inherit this class, it is VERY IMPORTANT that you implement each abstract method to the *exact* specifications the documentation specifies.
protected BaseDataReader(Stream stream, DeserializationContext context)
System.IO.Stream | stream | The base stream of the reader. |
DeserializationContext | context | The deserialization context to use. |
System.ArgumentNullException | The stream or context is null. |
System.ArgumentException | Cannot read from stream. |
public DeserializationContext Context { get; set; }
public int CurrentNodeDepth { get; }
public int CurrentNodeId { get; }
public string CurrentNodeName { get; }
public virtual Stream Stream { get; set; }
System.ArgumentNullException | value |
System.ArgumentException | Cannot read from stream |
public abstract void Dispose()
This call MUST (eventually) be followed by a corresponding call to
This call will change the values of the Sirenix.Serialization.IDataReader.IsInArrayNode, Sirenix.Serialization.IDataReader.CurrentNodeName, Sirenix.Serialization.IDataReader.CurrentNodeId and Sirenix.Serialization.IDataReader.CurrentNodeDepth properties to the correct values for the current array node.
public abstract bool EnterArray(out long length)
System.Int64 | length | The length of the array that was entered. |
System.Boolean |
|
This call MUST (eventually) be followed by a corresponding call to
This call will change the values of the Sirenix.Serialization.IDataReader.IsInArrayNode, Sirenix.Serialization.IDataReader.CurrentNodeName, Sirenix.Serialization.IDataReader.CurrentNodeId and Sirenix.Serialization.IDataReader.CurrentNodeDepth properties to the correct values for the current node.
public abstract bool EnterNode(out Type type)
System.Type | type | The type of the node. This value will be null if there was no metadata, or if the reader's serialization binder failed to resolve the type name. |
System.Boolean |
|
This call MUST have been preceded by a corresponding call to Sirenix.Serialization.IDataReader.EnterArray(System.Int64@).
This call will change the values of the Sirenix.Serialization.IDataReader.IsInArrayNode, Sirenix.Serialization.IDataReader.CurrentNodeName, Sirenix.Serialization.IDataReader.CurrentNodeId and Sirenix.Serialization.IDataReader.CurrentNodeDepth to the correct values for the node that was prior to the exited array node.
public abstract bool ExitArray()
System.Boolean |
|
This call MUST have been preceded by a corresponding call to Sirenix.Serialization.IDataReader.EnterNode(System.Type@).
This call will change the values of the Sirenix.Serialization.IDataReader.IsInArrayNode, Sirenix.Serialization.IDataReader.CurrentNodeName, Sirenix.Serialization.IDataReader.CurrentNodeId and Sirenix.Serialization.IDataReader.CurrentNodeDepth to the correct values for the node that was prior to the current node.
public abstract bool ExitNode()
System.Boolean |
|
public abstract string GetDataDump()
System.String |
protected abstract EntryType PeekEntry()
EntryType | The peeked entry. |
public abstract EntryType PeekEntry(out string name)
System.String | name | The name of the next entry, if it has one. |
EntryType | The type of the next entry. |
public virtual void PrepareNewSerializationSession()
If the call fails (and returns false
), it will skip the current entry value, unless that entry is an EndOfNode or an EndOfArray.
public abstract bool ReadBoolean(out bool value)
System.Boolean | value | The value that has been read. |
System.Boolean |
|
If the value of the stored integer is smaller than System.Byte.MinValue or larger than System.Byte.MaxValue, the result will be default(System.Byte).
If the call fails (and returns false
), it will skip the current entry value, unless that entry is an EndOfNode or an EndOfArray.
public abstract bool ReadByte(out byte value)
System.Byte | value | The value that has been read. |
System.Boolean |
|
If the string of the entry is longer than 1 character, the first character of the string will be taken as the result.
If the call fails (and returns false
), it will skip the current entry value, unless that entry is an EndOfNode or an EndOfArray.
public abstract bool ReadChar(out char value)
System.Char | value | The value that has been read. |
System.Boolean |
|
If the stored integer or floating point value is smaller than System.Decimal.MinValue or larger than System.Decimal.MaxValue, the result will be default(System.Decimal).
If the call fails (and returns false
), it will skip the current entry value, unless that entry is an EndOfNode or an EndOfArray.
public abstract bool ReadDecimal(out decimal value)
System.Decimal | value | The value that has been read. |
System.Boolean |
|
If the stored integer or floating point value is smaller than System.Double.MinValue or larger than System.Double.MaxValue, the result will be default(System.Double).
If the call fails (and returns false
), it will skip the current entry value, unless that entry is an EndOfNode or an EndOfArray.
public abstract bool ReadDouble(out double value)
System.Double | value | The value that has been read. |
System.Boolean |
|
If the call fails (and returns false
), it will skip the current entry value, unless that entry is an EndOfNode or an EndOfArray.
public abstract bool ReadExternalReference(out Guid guid)
System.Guid | guid | The external reference guid. |
System.Boolean |
|
If the call fails (and returns false
), it will skip the current entry value, unless that entry is an EndOfNode or an EndOfArray.
public abstract bool ReadExternalReference(out int index)
System.Int32 | index | The external reference index. |
System.Boolean |
|
If the call fails (and returns false
), it will skip the current entry value, unless that entry is an EndOfNode or an EndOfArray.
public abstract bool ReadExternalReference(out string id)
System.String | id | The external reference string. |
System.Boolean |
|
If the call fails (and returns false
), it will skip the current entry value, unless that entry is an EndOfNode or an EndOfArray.
public abstract bool ReadGuid(out Guid value)
System.Guid | value | The value that has been read. |
System.Boolean |
|
If the value of the stored integer is smaller than System.Int16.MinValue or larger than System.Int16.MaxValue, the result will be default(System.Int16).
If the call fails (and returns false
), it will skip the current entry value, unless that entry is an EndOfNode or an EndOfArray.
public abstract bool ReadInt16(out short value)
System.Int16 | value | The value that has been read. |
System.Boolean |
|
If the value of the stored integer is smaller than System.Int32.MinValue or larger than System.Int32.MaxValue, the result will be default(System.Int32).
If the call fails (and returns false
), it will skip the current entry value, unless that entry is an EndOfNode or an EndOfArray.
public abstract bool ReadInt32(out int value)
System.Int32 | value | The value that has been read. |
System.Boolean |
|
If the value of the stored integer is smaller than System.Int64.MinValue or larger than System.Int64.MaxValue, the result will be default(System.Int64).
If the call fails (and returns false
), it will skip the current entry value, unless that entry is an EndOfNode or an EndOfArray.
public abstract bool ReadInt64(out long value)
System.Int64 | value | The value that has been read. |
System.Boolean |
|
If the call fails (and returns false
), it will skip the current entry value, unless that entry is an EndOfNode or an EndOfArray.
public abstract bool ReadInternalReference(out int id)
System.Int32 | id | The internal reference id. |
System.Boolean |
|
null
value. This call will succeed if the next entry is an Null.
If the call fails (and returns false
), it will skip the current entry value, unless that entry is an EndOfNode or an EndOfArray.
public abstract bool ReadNull()
System.Boolean |
|
If the call fails (and returns false
), it will skip the current entry value, unless that entry is an EndOfNode or an EndOfArray.
public abstract bool ReadPrimitiveArray<T>(out T[] array)
where T : struct
T[] | array | The resulting primitive array. |
System.Boolean |
|
T | The element type of the primitive array. Valid element types can be determined using IsPrimitiveArrayType(Type). |
If the value of the stored integer is smaller than System.SByte.MinValue or larger than System.SByte.MaxValue, the result will be default(System.SByte).
If the call fails (and returns false
), it will skip the current entry value, unless that entry is an EndOfNode or an EndOfArray.
public abstract bool ReadSByte(out sbyte value)
System.SByte | value | The value that has been read. |
System.Boolean |
|
If the stored integer or floating point value is smaller than System.Single.MinValue or larger than System.Single.MaxValue, the result will be default(System.Single).
If the call fails (and returns false
), it will skip the current entry value, unless that entry is an EndOfNode or an EndOfArray.
public abstract bool ReadSingle(out float value)
System.Single | value | The value that has been read. |
System.Boolean |
|
If the call fails (and returns false
), it will skip the current entry value, unless that entry is an EndOfNode or an EndOfArray.
public abstract bool ReadString(out string value)
System.String | value | The value that has been read. |
System.Boolean |
|
protected abstract EntryType ReadToNextEntry()
EntryType | The next entry. |
If the value of the stored integer is smaller than System.UInt16.MinValue or larger than System.UInt16.MaxValue, the result will be default(System.UInt16).
If the call fails (and returns false
), it will skip the current entry value, unless that entry is an EndOfNode or an EndOfArray.
public abstract bool ReadUInt16(out ushort value)
System.UInt16 | value | The value that has been read. |
System.Boolean |
|
If the value of the stored integer is smaller than System.UInt32.MinValue or larger than System.UInt32.MaxValue, the result will be default(System.UInt32).
If the call fails (and returns false
), it will skip the current entry value, unless that entry is an EndOfNode or an EndOfArray.
public abstract bool ReadUInt32(out uint value)
System.UInt32 | value | The value that has been read. |
System.Boolean |
|
If the value of the stored integer is smaller than System.UInt64.MinValue or larger than System.UInt64.MaxValue, the result will be default(System.UInt64).
If the call fails (and returns false
), it will skip the current entry value, unless that entry is an EndOfNode or an EndOfArray.
public abstract bool ReadUInt64(out ulong value)
System.UInt64 | value | The value that has been read. |
System.Boolean |
|
public virtual void SkipEntry()