public void Write(ITreeWriter writer) { writer.WriteStartObject(); writer.WritePropertyName(nameof(List)); writer.WriteList(List); writer.WritePropertyName(nameof(StringDictionary)); writer.WriteDictionary(StringDictionary); writer.WritePropertyName(nameof(IntDictionary)); writer.WriteDictionary(IntDictionary); writer.WriteEndObject(); }
public void Write(ITreeWriter writer) { // Merge changed small values under cutoff into SmallValueArray Trim(); writer.WriteStartObject(); if (_smallValueArray?.Length > 0) { // If there are any non-empty values, write the text and end positions writer.WriteBlockArray(Names.ValueEnd, _valueEndInPage); writer.WriteBlockArray(Names.SmallValues, _smallValueArray); // If there is more than one page, write page starts int pages = (Count / PageRowCount) + 1; if (pages > 1) { writer.WriteBlockArray(Names.PageStart, _pageStartInChapter); } } else if (Count > 0) { // If there is no text but a non-zero count, we must preserve the count writer.Write(Names.Count, Count); } // If there are any large values, write them if (_largeValueDictionary?.Count > 0) { writer.WritePropertyName(Names.LargeValues); writer.WriteDictionary(_largeValueDictionary); } writer.WriteEndObject(); }
public void Write(ITreeWriter writer) { writer.WriteStartObject(); if (DefaultValue == false && Count == 0) { // If all values are default false, only write Capacity; Count defaults back to zero on read writer.Write(Names.Capacity, Capacity); } else if (DefaultValue == true && Count == Capacity) { // If all values are default true, only write Count+Capacity (Array will be re-created with all default) writer.Write(Names.Count, Count); writer.Write(Names.Capacity, Capacity); } else if (Capacity > 0) { writer.Write(Names.Count, Count); writer.Write(Names.Capacity, Capacity); writer.WritePropertyName(Names.Array); writer.WriteBlockArray(Array, 0, Math.Min(Array.Length, (Capacity + 31) >> 5)); } writer.WriteEndObject(); }
public static void Write(this ITreeWriter writer, string name, ITreeSerializable value) { if (value != null) { writer.WritePropertyName(name); value.Write(writer); } }
// WriteObject supports writing a subcomponent with name and value in one call. public static void WriteObject(this ITreeWriter writer, string name, ITreeSerializable component) { if (component != null) { writer.WritePropertyName(name); component.Write(writer); } }
public void Write(ITreeWriter writer) { // Write non-empty tables only writer.WriteStartObject(); foreach (var pair in Tables) { if (pair.Value.Count > 0) { writer.WritePropertyName(pair.Key); pair.Value.Write(writer); } } writer.WriteEndObject(); }
public static void WriteDictionary <T>(this ITreeWriter writer, IReadOnlyDictionary <string, T> dictionary) where T : ITreeSerializable { if (dictionary == null) { writer.WriteNull(); return; } writer.WriteStartObject(); foreach (var item in dictionary) { writer.WritePropertyName(item.Key); item.Value.Write(writer); } writer.WriteEndObject(); }
public void Write(ITreeWriter writer) { writer.WriteStartObject(); writer.Write(Names.Count, Count); // Write non-empty columns only writer.WritePropertyName(Names.Columns); writer.WriteStartObject(); foreach (var pair in Columns) { if (pair.Value.Count > 0) { writer.Write(pair.Key, pair.Value); } } writer.WriteEndObject(); writer.WriteEndObject(); }
public static void Write(this ITreeWriter writer, string name, string value) { writer.WritePropertyName(name); writer.WriteValue(value); }
public static void WriteBlockArray <T>(this ITreeWriter writer, string name, T[] array, int index = 0, int count = -1) where T : unmanaged { writer.WritePropertyName(name); writer.WriteBlockArray <T>(array, index, count); }