Пример #1
0
        public static Dictionary <int, T> ReadIntDictionary <T>(this ITreeReader reader, Func <T> ctor) where T : ITreeSerializable
        {
            if (reader.TokenType == TreeToken.Null)
            {
                return(null);
            }
            Dictionary <int, T> result = new Dictionary <int, T>();

            reader.Expect(TreeToken.StartArray);
            reader.Read();

            int[] keys = reader.ReadBlockArray <int>();

            reader.Read();
            reader.Expect(TreeToken.StartArray);
            reader.Read();

            for (int i = 0; i < keys.Length; ++i)
            {
                int key = keys[i];

                T value = ctor();
                value.Read(reader);

                result[key] = value;

                reader.Read();
            }

            reader.Expect(TreeToken.EndArray);
            reader.Read();

            reader.Expect(TreeToken.EndArray);
            return(result);
        }
Пример #2
0
 public void Read(ITreeReader reader)
 {
     Array        = reader.ReadBlockArray <T>();
     Index        = 0;
     Count        = Array.Length;
     IsExpandable = false;
 }
 public void Read(ITreeReader reader)
 {
     // Verify classes can serialize a single item directly
     Array = reader.ReadBlockArray<T>();
 }