|
Enhanced C#
Loyc library documentation
|
An optimized implementation of ISyncManager for writing JSON objects. SupportsReordering and SupportsDeduplication are both true. More...
An optimized implementation of ISyncManager for writing JSON objects. SupportsReordering and SupportsDeduplication are both true.
This is a struct rather than a class for performance reasons. Don't try to use a default(Writer); it'll throw NullReferenceException.
Properties | |
| object | CurrentObject [set] |
Public Member Functions | |
| bool int object Object | BeginSubObject (FieldId name, object?childKey, ObjectMode mode, int listLength=-1) |
| void | EndSubObject () |
| SyncType | GetFieldType (FieldId name, SyncType expectedType=SyncType.Unknown) |
| string | SyncTypeTag (string?tag) |
| bool | Sync (FieldId name, bool savable) |
| int | Sync (FieldId name, int savable, int bits, bool signed=true) |
| long | Sync (FieldId name, long savable, int bits, bool signed=true) |
| BigInteger | Sync (FieldId name, BigInteger savable, int bits, bool signed=true) |
| string | Sync (FieldId name, string?savable, ObjectMode mode=ObjectMode.Normal) |
| IBufferWriter< byte > | Flush () |
| Ensures that all written output has been registered with the IBufferWriter{byte} object with which this writer was initialized, and then returns it. If you called NewWriter without arguments, this function returns a ArrayBufferWriter{T} (see example below). More... | |
| List | SyncListBoolImpl< Scanner, List, ListBuilder > (FieldId name, Scanner scanner, List?saving, ListBuilder builder, ObjectMode mode, int tupleLength=-1) |
| List | SyncListCharImpl< Scanner, List, ListBuilder > (FieldId name, Scanner scanner, List?saving, ListBuilder builder, ObjectMode mode, int tupleLength=-1) |
| List | SyncListByteImpl< Scanner, List, ListBuilder > (FieldId name, Scanner scanner, List?saving, ListBuilder builder, ObjectMode mode, int tupleLength=-1) |
| IBufferWriter<byte> SyncJson.Writer.Flush | ( | ) |
Ensures that all written output has been registered with the IBufferWriter{byte} object with which this writer was initialized, and then returns it. If you called NewWriter without arguments, this function returns a ArrayBufferWriter{T} (see example below).
It is only necessary to call this method just after writing a primitive (e.g. number or string), because flushing happens automatically when ISyncManager.EndSubObject is used to finish writing an object or list.
Here's an example that uses this method to write a primitive:
<![CDATA[
var writer = SyncJson.NewWriter();
writer.Sync(null, 1234.5);
var output = (ArrayBufferWriter<byte>) writer.Flush(); // Output: 1234.5
Console.WriteLine("Output: " + Encoding.UTF8.GetString(output.WrittenSpan));
]]>
1.8.7