ES2Reader
Properties
ES2Settings | settings | The ES2Settings object containing settings for this ES2Reader." |
reader | An underlying BinaryReader for this ES2Reader. |
Methods
ES2Reader.Create | Creates an ES2Reader. |
ES2Reader.Read | Reads data of a supported type from the reader. |
ES2Reader.ReadArray | Reads an array of a supported type from the reader. |
ES2Reader.Read2DArray | Reads a 2D array of a supported type from the reader. |
ES2Reader.Read3DArray | Reads a 3D array of a supported type from the reader. |
ES2Reader.ReadList | Reads a List of a supported type from the reader. |
ES2Reader.ReadDictionary | Reads a Dictionary of a supported type from the reader. |
ES2Reader.ReadStack | Reads a Stack of a supported type from the reader. |
ES2Reader.ReadHashSet | Reads a HashSet of a supported type from the reader. |
ES2Reader.TagExists | Whether a tag exists in this reader. |
ES2Reader.Dispose | Manually disposes of this ES2Reader. |
Description
An ES2Reader can be used to manually read data from a file. This can sometimes improve performance, though you will usually see more benefit from using ES2.LoadAll to load tagged data.
You can also Read sequential data from an ES2Reader, which is the fastest way to load data, but the data must have been written sequentially using ES2Writer.
You must use ES2Reader.Create to create the ES2Reader.
If you are not using your ES2Reader in a using block, you must also call ES2Reader.Dispose when you are finished with it.
For more information, see Faster Saving and Loading using ES2Writer and ES2Reader.
C#
Saving tags to an ES2Writer
1 2 3 4 5 6 7 |
using(ES2Reader reader = ES2Reader.Create("myFile.txt")) { // Read data from the file in any order. reader.Read<Transform>("transformTag", this.transform); this.name = reader.Read<string>("nameTag"); int[] myIntArray = reader.ReadArray<int>("intArrayTag"); } |
Saving data sequentially to an ES2Writer
1 2 3 4 5 6 7 |
using(ES2Reader reader = ES2Reader.Create("myFile.txt")) { // Read the data from the file in the same order as we saved it. this.name = reader.Read<string>(); reader.Read<Transform>(this.transform); int[] myIntArray = reader.ReadArray<int>(); } |
JS
Saving tags to an ES2Writer
1 2 3 4 5 6 7 |
var reader : ES2Reader = ES2Reader.Create("myFile.txt")) // Read data from the file in any order. reader.Read.<Transform>("transformTag", this.transform); this.name = reader.Read.<String>("nameTag"); int[] myIntArray = reader.ReadArray.<int>("intTag"); // Remember to dispose when we're finished. reader.Dispose(); |
Saving data sequentially to an ES2Writer
1 2 3 4 5 6 7 |
var reader : ES2Reader = ES2Reader.Create("myFile.txt")) // Read the data from the file in the same order as we saved it. this.name = reader.Read.<String>(); reader.Read.<Transform>(this.transform); var myIntArray = reader.ReadArray.<int>(); // Remember to dispose when we're finished. reader.Dispose(); |