Ejemplo n.º 1
0
        public static void WriteList <T>(this ITreeWriter writer, IReadOnlyList <T> list) where T : ITreeSerializable
        {
            if (list == null)
            {
                writer.WriteNull(); return;
            }

            writer.WriteStartArray();

            foreach (T item in list)
            {
                item.Write(writer);
            }

            writer.WriteEndArray();
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        public static void WriteDictionary <T>(this ITreeWriter writer, IReadOnlyDictionary <int, T> dictionary) where T : ITreeSerializable
        {
            if (dictionary == null)
            {
                writer.WriteNull(); return;
            }

            writer.WriteStartArray();

            int[] keys = dictionary.Keys.ToArray();
            writer.WriteBlockArray(keys);

            writer.WriteStartArray();

            for (int i = 0; i < keys.Length; ++i)
            {
                dictionary[keys[i]].Write(writer);
            }

            writer.WriteEndArray();

            writer.WriteEndArray();
        }