ES2Writer.Write
Write with Tag
public void Write<T>(T data, string tag)Parameters
T | The type of the data we want to write. Must be on the Supported Types list." |
data |
The data that we want to write. |
tag |
The tag that we want to write the data with. |
Description
Writes the data to the ES2Writer with the given tag. This method writes the data with header data so that it can be randomly accessed using tags.
Note that the data will not be stored to file until the Save() method of the writer is called.
C#
Saving randomly-accessible data with 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(); } |
JS
Saving randomly-accessible data with 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(false); writer.Dispose(); |
Write Sequentially
public void Write<T>(T data)Parameters
T | The type of the data we want to load. Must be on the Supported Types list." |
data |
The data that we want to write. |
tag |
The tag that we want to write the data with. |
Description
Writes the data to the ES2Writer sequentially, which provides better performance than writing with random-access tags.
Data written sequentially must be read in the same order that it is written, and cannot be used in conjunction with tags.
When saving sequentially, you should call the ES2Writer’s Save(false) method to store the data. The false parameter tells Easy Save that we’re not saving tags.
C#
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 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(); |