ES2Writer
Properties
ES2Settings | settings | The ES2Settings object containing settings for this ES2Writer. |
writer | An underlying BinaryWriter for this ES2Writer. |
Methods
ES2Writer.Create | Creates an ES2Writer. |
ES2Writer.Write | Writes data of a supported type to the writer. |
ES2Writer.Delete | Marks a tag to be deleted. |
ES2Writer.Save | Stores the data in this ES2Writer to a permanent file. |
ES2Writer.Dispose | Manually disposes of this ES2Writer. |
Description
An ES2Writer can be used to write multiple pieces of data to a single file at once, improving performance. It can then be read using an ES2Reader or ES2 methods.
You can also Write sequentially to an ES2Writer, which is significantly faster than storing data which can be randomly accessed with tags.
You must use ES2Writer.Create to create the ES2Writer. Once you have written your data to the writer, you should then call ES2Writer.Save to store it.
If you are not using your ES2Writer in a using block, you must also call ES2Writer.Dispose when you are finished with it.
Also note that you should not write multiple tags of the same name to an ES2Writer, as this may cause unexpected behaviour.
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 8 9 |
using(ES2Writer writer = ES2Writer.Create("myFile.txt")) { // Write our data to the file. writer.Write(this.name, "nameTag"); writer.Write(this.transform, "transformTag"); writer.Write(new int[]{1,2,3},"intArrayTag"); // Remember to save when we're done. writer.Save(); } |
Saving data sequentially to an ES2Writer
1 2 3 4 5 6 7 8 9 |
using(ES2Writer writer = ES2Writer.Create("myFile.txt")) { // Write our data to the file in the order we are going to read it. writer.Write(this.name); writer.Write(this.transform); writer.Write(new int[]{1,2,3}); // Remember to save when we're done. writer.Save(false); } |
JS
Saving tags to an ES2Writer
1 2 3 4 5 6 7 8 |
var writer : ES2Writer = ES2Writer.Create("myFile.txt"); // Write our data to the file in the order we are going to read it. writer.Write(this.name, "nameTag"); writer.Write(this.transform, "transformTag"); writer.Write(new int[]{1,2,3}, "intArrayTag"); // Remember to save and dispose when you're finished. writer.Save(); writer.Dispose(); |
Saving data sequentially to an ES2Writer
1 2 3 4 5 6 7 8 |
var writer : ES2Writer = ES2Writer.Create("myFile.txt"); // Write our data to the file in the order we are going to read it. writer.Write(this.name); writer.Write(this.transform); writer.Write(new int[]{1,2,3}); // Remember to save and dispose when you're finished. writer.Save(false); writer.Dispose(); |