Exemplo n.º 1
0
        protected override void ReadData(BinaryReader reader)
        {
            int length = reader.ReadInt32();

            _keyValuePairs = new KeyValuePair <StringBlock, TValue> [length];

            ConstructorInfo blockConstructorInfo =
                typeof(TValue).GetConstructor(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance,
                                              null,
                                              new[] { typeof(GameSave), typeof(Tuple <int, uint>) }, null);

            if (blockConstructorInfo == null)
            {
                throw new Exception("Constructor for bound " + typeof(TValue) + " not found.");
            }

            for (int i = 0; i < length; i++)
            {
                var key   = StringBlock.FromSave(GameSave, ReadAddress(reader));
                var value = (TValue)(blockConstructorInfo.Invoke(new object[] { GameSave, ReadAddress(reader) }));
                _keyValuePairs[i] = new KeyValuePair <StringBlock, TValue>(key, value);
            }
        }
Exemplo n.º 2
0
 protected override void ForgetData()
 {
     _saveName   = null;
     _chunkTable = null;
 }