示例#1
0
        public void ConstructorTest()
        {
            byte[] data   = { 1, 2, 3 };
            var    stream = new FastStreamReader(data);

            // Make sure data is copied/cloned
            data[0] = 255;

            Helper.ComparePrivateField(stream, "data", new byte[] { 1, 2, 3 });
            Helper.ComparePrivateField(stream, "position", 0);
        }
示例#2
0
        public void ConstructorTest()
        {
            byte[] data   = { 1, 2, 3 };
            var    stream = new FastStreamReader(data);

            // Make sure data is NOT cloned (default behavior)
            data[0] = 255;

            Helper.ComparePrivateField(stream, "data", new byte[] { 255, 2, 3 });
            Helper.ComparePrivateField(stream, "position", 0);
        }
示例#3
0
        public void TryDeserialize_FailTest(FastStreamReader stream, MockDeserializableSigScript scr, string expErr)
        {
            var tx = new TxIn()
            {
                SigScript = scr
            };
            bool b = tx.TryDeserialize(stream, out string error);

            Assert.False(b);
            Assert.Equal(expErr, error);
        }
示例#4
0
        public void TryRead_Fail_SmallStreamTest()
        {
            FastStreamReader stream = new FastStreamReader(new byte[3] {
                1, 2, 3
            });
            bool b = LockTime.TryRead(stream, out LockTime actual, out string error);

            Assert.False(b);
            Assert.Equal(Err.EndOfStream, error);
            Helper.ComparePrivateField(actual, "value", 0U);
        }
示例#5
0
        public void TryReadByteArrayTest()
        {
            var  stream = new FastStreamReader(Helper.GetBytes(12));
            bool b      = stream.TryReadByteArray(10, out byte[] actual);

            byte[] expected = Helper.GetBytes(10);

            Assert.True(b);
            Assert.Equal(expected, actual);
            Assert.Equal(10, stream.GetCurrentIndex());
        }
示例#6
0
        public void GetRemainingBytesCountTest()
        {
            var stream = new FastStreamReader(new byte[10]);

            Assert.Equal(10, stream.GetRemainingBytesCount());
            _ = stream.TryReadByteArray(2, out _);
            Assert.Equal(8, stream.GetRemainingBytesCount());
            _ = stream.TryReadByteArray(1, out _);
            Assert.Equal(7, stream.GetRemainingBytesCount());
            _ = stream.TryReadByteArray(7, out _);
            Assert.Equal(0, stream.GetRemainingBytesCount());
        }
示例#7
0
        public void CompareBytesTest(byte[] data, byte[] other, bool skip, bool expected)
        {
            var stream = new FastStreamReader(data);

            if (skip)
            {
                stream.SkipOneByte();
            }
            bool actual = stream.CompareBytes(other);

            Assert.Equal(expected, actual);
        }
示例#8
0
        public void TryDeserialize_InvalidServiceTest()
        {
            NetworkAddress addr   = new NetworkAddress();
            var            stream = new FastStreamReader(Helper.HexToBytes("ffffffffffffffff00000000000000000000ffffc0000233208d"));
            bool           b      = addr.TryDeserialize(stream, out string error);

            Assert.True(b, error);
            Assert.Null(error);
            Assert.Equal(ulong.MaxValue, (ulong)addr.NodeServices);
            Assert.Equal(IPAddress.Parse("192.0.2.51"), addr.NodeIP);
            Assert.Equal((ushort)8333, addr.NodePort);
        }
示例#9
0
        public void SizeTest()
        {
            // MainNet block #557991 containing 2 txs with witness
            var  blk    = new Block();
            var  stream = new FastStreamReader(Helper.HexToBytes("000080206689707b09f987d19036a404af1cba3e4abe93fc216931000000000000000000f789b5842f2ff0d1e3ebb4e8321fb53f14b9ee22d2e0def211e3f681e1322f7ca8d5375ca51832177894b5eb02010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff5503a783081c4d696e656420627920416e74506f6f6c31323052000102205c37d5a8fabe6d6db555462795a64abe912fd1c529d8a154aff792f7ec154c6a959c449047d1898404000000000000006019000045dc0000ffffffff021889814a000000001976a914edf10a7fac6b32e24daa5305c723f3de58db1bc888ac0000000000000000266a24aa21a9ed02a7c90fe9795d0af5206b29acea5111d03eb8219fff0a67577a5c948244186901200000000000000000000000000000000000000000000000000000000000000000000000000100000000010145140fe1397a86a940a55e5207d719593143bc23e5fa12ab84c5e61a1b9d852012000000171600140cdda6079ebeaf15d6c6ae29a04b71aeb9842c8affffffff0228e525000000000016001481cf43e0c29625336d275db4e586701c052bafcfb88c2900000000001976a914206e6b76851048928bf7d84ace3b94239ccdf53888ac02473044022056fa2da21a28b2ab9d83dc0cdb18f2d207a7a12af24c1e958056ba28dd29247d02203be11e97bbc3ff43d8907091cb3c5e665ae08947723d11e0d53392e7b0f03634012103cd354d51e44ad77599ba9fce6727c08e5925b9dcaedcea8e5be0bca25e65af9200000000"));
            bool b      = blk.TryDeserialize(stream, out string error);

            Assert.True(b, error);
            Assert.Equal(582, blk.TotalSize);
            Assert.Equal(437, blk.StrippedSize);
            Assert.Equal(1893, blk.Weight);
        }
示例#10
0
        public void TryDeserializeTest()
        {
            PingPayload      ping   = new PingPayload();
            FastStreamReader stream = new FastStreamReader(new byte[8] {
                2, 0, 0, 0, 0, 0, 0, 0
            });
            bool b = ping.TryDeserialize(stream, out string error);

            Assert.True(b, error);
            Assert.Null(error);
            Assert.Equal(2L, ping.Nonce);
        }
示例#11
0
        public void SkipOneByteTest()
        {
            var stream = new FastStreamReader(new byte[5]);

            Assert.Equal(0, stream.GetCurrentIndex());

            stream.SkipOneByte();
            Assert.Equal(1, stream.GetCurrentIndex());

            stream.SkipOneByte();
            Assert.Equal(2, stream.GetCurrentIndex());
        }
示例#12
0
        public void GetCurrentIndexTest()
        {
            var stream = new FastStreamReader(new byte[10]);

            Assert.Equal(0, stream.GetCurrentIndex());
            _ = stream.TryReadByteArray(3, out _);
            Assert.Equal(3, stream.GetCurrentIndex());
            _ = stream.TryReadByteArray(5, out _);
            Assert.Equal(8, stream.GetCurrentIndex());
            _ = stream.TryReadByteArray(2, out _);
            Assert.Equal(10, stream.GetCurrentIndex());
        }
示例#13
0
        public void TryDeserializeTest()
        {
            var  addr   = new NetworkAddressWithTime();
            var  stream = new FastStreamReader(Helper.HexToBytes("d91f4854010000000000000000000000000000000000ffffc0000233208d"));
            bool b      = addr.TryDeserialize(stream, out string error);

            Assert.True(b, error);
            Assert.Null(error);
            Assert.Equal(1414012889U, addr.Time);
            Assert.Equal(NodeServiceFlags.NodeNetwork, addr.NodeServices);
            Assert.Equal(IPAddress.Parse("192.0.2.51"), addr.NodeIP);
            Assert.Equal((ushort)8333, addr.NodePort);
        }
示例#14
0
        public void CheckRemainingTest()
        {
            var stream = new FastStreamReader(new byte[5]);

            Assert.True(stream.CheckRemaining(1));
            Assert.True(stream.CheckRemaining(5));
            Assert.False(stream.CheckRemaining(6));

            _ = stream.TryReadByteArray(2, out _);
            Assert.True(stream.CheckRemaining(1));
            Assert.False(stream.CheckRemaining(5));
            Assert.False(stream.CheckRemaining(6));
        }
示例#15
0
        public void TryDeserialize_FailTest(FastStreamReader stream, MockDeserializableTx tx, string expErr)
        {
            TxPayload pl = new TxPayload()
            {
                Tx = tx
            };

            bool b = pl.TryDeserialize(stream, out string error);

            Assert.False(b);
            Assert.Equal(expErr, error);
            // Mock tx has its own tests.
        }
示例#16
0
        public void TryDeserializeTest()
        {
            FeeFilterPayload pl     = new FeeFilterPayload();
            FastStreamReader stream = new FastStreamReader(new byte[8] {
                0x7c, 0xbd, 0, 0, 0, 0, 0, 0
            });
            bool b = pl.TryDeserialize(stream, out string error);

            Assert.True(b, error);
            Assert.Null(error);
            Assert.Equal(48_508UL, pl.FeeRate);
            Assert.Equal(PayloadType.FeeFilter, pl.PayloadType);
        }
示例#17
0
        public void TryDeserialize_FailTest(FastStreamReader stream, MockDeserializableBlock block, string expErr)
        {
            BlockPayload pl = new BlockPayload()
            {
                BlockData = block
            };

            bool b = pl.TryDeserialize(stream, out string error);

            Assert.False(b);
            Assert.Equal(expErr, error);
            // Mock block has its own tests.
        }
示例#18
0
        /// <summary>
        /// Creates a new instance of <see cref="Signature"/> by reading it from a DER encoded byte array with loose rules.
        /// Return value indicates success.
        /// </summary>
        /// <param name="derSig">Signature bytes encoded using DER encoding</param>
        /// <param name="result">Resulting signature (null in case of failure)</param>
        /// <param name="error">Error message (null if sucessful, otherwise contains information about the failure)</param>
        /// <returns>True if successful, otherwise false.</returns>
        public static bool TryReadLoose(byte[] derSig, out Signature result, out string error)
        {
            result = null;

            if (derSig == null)
            {
                error = "Byte array can not be null.";
                return(false);
            }

            // Min = 3006[0201(01)0201(01)]-01
            if (derSig.Length < 9)
            {
                // This also handles the Length == 0 case
                error = "Invalid DER encoding length.";
                return(false);
            }

            FastStreamReader stream = new FastStreamReader(derSig);

            if (!stream.TryReadByte(out byte seqTag) || seqTag != SequenceTag)
            {
                error = "Sequence tag was not found in DER encoded signature.";
                return(false);
            }

            if (!stream.TryReadDerLength(out int seqLen))
            {
                error = "Invalid sequence length.";
                return(false);
            }

            if (seqLen < 6 || !stream.CheckRemaining(seqLen + 1)) // +1 is the SigHash byte (at least 1 byte)
            {
                error = "Invalid total length according to sequence length.";
                return(false);
            }

            if (!stream.TryReadByte(out byte intTag1) || intTag1 != IntegerTag)
            {
                error = "First integer tag was not found in DER encoded signature.";
                return(false);
            }

            if (!stream.TryReadDerLength(out int rLen) || rLen == 0)
            {
                error = "Invalid R length.";
                return(false);
            }

            if (!stream.TryReadByteArray(rLen, out byte[] rBa))
示例#19
0
        public void TryDeserializeTest()
        {
            BlockPayload pl = new BlockPayload()
            {
                BlockData = new MockDeserializableBlock(0, 3)
            };
            FastStreamReader stream = new FastStreamReader(new byte[3]);
            bool             b      = pl.TryDeserialize(stream, out string error);

            Assert.True(b, error);
            Assert.Null(error);
            // Mock block has its own tests.
            Assert.Equal(PayloadType.Block, pl.PayloadType);
        }
示例#20
0
        public void TryDeserializeTest()
        {
            TxPayload pl = new TxPayload()
            {
                Tx = new MockDeserializableTx(0, 3)
            };
            FastStreamReader stream = new FastStreamReader(new byte[3]);
            bool             b      = pl.TryDeserialize(stream, out string error);

            Assert.True(b, error);
            Assert.Null(error);
            // Mock tx has its own tests.
            Assert.Equal(PayloadType.Tx, pl.PayloadType);
        }
示例#21
0
        public override bool TryDeserialize(FastStreamReader stream, out string error)
        {
            int actualIndex = stream.GetCurrentIndex();

            Assert.Equal(expectedIndex, actualIndex);

            if (!stream.TryReadByteArray(bytesToRead, out _))
            {
                Assert.True(false, "Stream doesn't have enough bytes.");
            }

            error = retError;
            return(string.IsNullOrEmpty(retError));
        }
示例#22
0
        public void TryDeserializeTest()
        {
            byte[] mockBlkHash = Helper.GetBytes(32);
            // 2 random small size tx taken from a block explorer:
            string tx1    = "0100000001defccf0ab6f1ce363820fd8ffc59e1a455e520ad37ed2b4b781fddbffbe0b1fd00000000025200ffffffff01151605000000000017a914de2b27afd4498dc5688f5b511a8be5aad26820338700000000";
            string tx2    = "0100000001310f060f19fd067aed414c3902ac70693c67f753dcc34e6bddcfe4fabe6aa32000000000025100ffffffff01ee340200000000001976a9145c0189a6094fe13177cd47b9a9ee0ec92509365388ac00000000";
            var    stream = new FastStreamReader(Helper.HexToBytes($"{Helper.GetBytesHex(32)}02{tx1}{tx2}"));
            var    pl     = new BlockTxnPayload();
            bool   b      = pl.TryDeserialize(stream, out string error);

            Assert.True(b, error);
            Assert.Null(error);
            Assert.Equal(mockBlkHash, pl.BlockHash);
            Assert.Equal(2, pl.Transactions.Length);
        }
示例#23
0
        public void TryDeserializeTest(Inventory[] items, byte[] data)
        {
            var  pl      = new InvPayload();
            var  stream  = new FastStreamReader(data);
            bool success = pl.TryDeserialize(stream, out string error);

            Assert.True(success, error);
            Assert.Null(error);
            Assert.Equal(items.Length, pl.InventoryList.Length);
            for (int i = 0; i < items.Length; i++)
            {
                Assert.Equal(items[i].InvType, pl.InventoryList[i].InvType);
                Assert.Equal(items[i].Hash, pl.InventoryList[i].Hash);
            }
        }
示例#24
0
        public void TryDeserializeTest()
        {
            GetBlocksPayload pl     = new GetBlocksPayload();
            FastStreamReader stream = new FastStreamReader(Helper.HexToBytes(PayloadHex));
            bool             b      = pl.TryDeserialize(stream, out string error);

            byte[] hd1 = Helper.HexToBytes(Header1);
            byte[] hd2 = Helper.HexToBytes(Header2);

            Assert.True(b, error);
            Assert.Null(error);
            Assert.Equal(Version, pl.Version);
            Assert.Equal(new byte[][] { hd1, hd2 }, pl.Hashes);
            Assert.Equal(new byte[32], pl.StopHash);
            Assert.Equal(PayloadType.GetBlocks, pl.PayloadType);
        }
示例#25
0
        public void TryDeserializeTest(byte[] data, MockDeserializableSigScript scr, byte[] expHash, uint expIndex, uint expSeq)
        {
            TxIn tx = new TxIn()
            {
                SigScript = scr
            };
            FastStreamReader stream = new FastStreamReader(data);
            bool             b      = tx.TryDeserialize(stream, out string error);

            Assert.True(b, error);
            Assert.Null(error);
            Assert.Equal(expHash, tx.TxHash);
            Assert.Equal(expIndex, tx.Index);
            Assert.Equal(expSeq, tx.Sequence);
            // Mock script has its own tests.
        }
示例#26
0
 private static object Deserialize(FastStreamReader streamReader)
 {
     using (PersistReader reader = new PersistReader())
     {
         bool enableTypeRemapping = Persist.EnableTypeRemapping;
         Persist.EnableTypeRemapping = false;
         bool requireAllPersistable = Persist.RequireAllPersistable;
         Persist.RequireAllPersistable = true;
         try
         {
             reader.Load(streamReader, null);
         }
         finally
         {
             Persist.EnableTypeRemapping   = enableTypeRemapping;
             Persist.RequireAllPersistable = requireAllPersistable;
         }
         return((reader.Count > 0) ? reader[0] : null);
     }
 }
示例#27
0
        public void SkipTest()
        {
            var stream = new FastStreamReader(new byte[10]);

            Assert.Equal(0, stream.GetCurrentIndex());

            stream.Skip(0);
            Assert.Equal(0, stream.GetCurrentIndex());

            stream.Skip(1);
            Assert.Equal(1, stream.GetCurrentIndex());

            stream.Skip(4);
            Assert.Equal(5, stream.GetCurrentIndex());

            stream.Skip(7);
            Assert.Equal(12, stream.GetCurrentIndex());

            Assert.False(stream.CheckRemaining(1));
        }
示例#28
0
        /// <summary>
        /// Loads data that was written to the game cache with the given tag,
        /// and deserializes it back into an object instance.
        /// </summary>
        /// <param name="tag">A unique string that identifies the cached data to be loaded.</param>
        /// <returns>The deserialized object instance that was stored in the game cache.</returns>
        public object LoadTuningData(string tag)
        {
            if (!this.mIsCacheVerified)
            {
                this.VerifyCache();
            }
            if (!this.mIsCachingEnabled)
            {
                return(null);
            }
            uint handle = CacheManager_ReadCachedDataAsStream(tag);

            if (handle == 0)
            {
                return(null);
            }
            using (FastStreamReader reader = new FastStreamReader(handle))
            {
                return(Deserialize(reader));
            }
        }
示例#29
0
        public void TryDeserializeTest()
        {
            AddrPayload      pl     = new AddrPayload();
            FastStreamReader stream = new FastStreamReader(Helper.HexToBytes("02" + addr1Hex + addr2Hex));
            bool             b      = pl.TryDeserialize(stream, out string error);

            Assert.True(b, error);
            Assert.Null(error);
            Assert.Equal(2, pl.Addresses.Length);

            Assert.Equal(addr1.Time, pl.Addresses[0].Time);
            Assert.Equal(addr1.NodeServices, pl.Addresses[0].NodeServices);
            Assert.Equal(addr1.NodeIP, pl.Addresses[0].NodeIP);
            Assert.Equal(addr1.NodePort, pl.Addresses[0].NodePort);

            Assert.Equal(addr2.Time, pl.Addresses[1].Time);
            Assert.Equal(addr2.NodeServices, pl.Addresses[1].NodeServices);
            Assert.Equal(addr2.NodeIP, pl.Addresses[1].NodeIP);
            Assert.Equal(addr2.NodePort, pl.Addresses[1].NodePort);

            Assert.Equal(PayloadType.Addr, pl.PayloadType);
        }
示例#30
0
        /// <inheritdoc/>
        public override bool TryDeserialize(FastStreamReader stream, out string error)
        {
            if (stream is null)
            {
                error = "Stream can not be null.";
                return(false);
            }

            if (!CompactInt.TryRead(stream, out CompactInt count, out error))
            {
                return(false);
            }

            Headers = new Block[count];
            for (int i = 0; i < (int)count; i++)
            {
                Block temp = new Block();
                if (!temp.TryDeserializeHeader(stream, out error))
                {
                    return(false);
                }
                Headers[i] = temp;

                if (!stream.TryReadByte(out byte zero))
                {
                    error = Err.EndOfStream;
                    return(false);
                }
                if (zero != 0)
                {
                    error = "Transaction count in a headers message must be zero.";
                    return(false);
                }
            }

            error = null;
            return(true);
        }
示例#31
0
 public void Read(FastStreamReader reader, IPersistReader persistReader)
 {
     int position = reader.Position;
     reader.ReadUInt32();
     uint num2 = reader.ReadUInt32();
     uint num3 = reader.ReadUInt32();
     uint num4 = reader.ReadUInt32();
     uint num5 = reader.ReadUInt32();
     int[] numArray = new int[num2];
     reader.Seek(position + ((int)num3), SeekOrigin.Begin);
     for (uint i = 0x0; i < num2; i++)
     {
         numArray[i] = reader.ReadInt32();
     }
     reader.Seek(position + ((int)num5), SeekOrigin.Begin);
     mMethodList.Capacity = (int)num4;
     mMethodList.Clear();
     for (uint j = 0x0; j < num4; j++)
     {
         MethodEntry entry;
         MethodInfo methodInfo = (MethodInfo)persistReader.ReadReferenceForceLive();
         if (ScriptCore.ExceptionTrap.GetOption("ResetTaskStates") == 1)
         {
             entry.checksum = 0;
         }
         else
         {
             entry.checksum = reader.ReadUInt32();
         }
         if (methodInfo != null)
         {
             uint num8;
             entry.handle = methodInfo.MethodHandle;
             if (!ScriptCore.TaskControl.GetMethodChecksum(entry.handle, out num8))
             {
                 entry.handle = new RuntimeMethodHandle();
             }
             else if (num8 != entry.checksum)
             {
                 entry.handle = new RuntimeMethodHandle();
             }
             else if (!this.IsMethodSaveSafe(methodInfo))
             {
             }
         }
         else
         {
             entry.handle = new RuntimeMethodHandle();
         }
         this.mMethodList.Add(entry);
     }
     this.mSavedTaskContexts = new ScriptCore.SavedTaskContext[num2];
     for (uint k = 0x0; k < num2; k++)
     {
         int num10 = numArray[k];
         if (num10 == 0x0)
         {
             this.mSavedTaskContexts[k] = InvalidSavedTaskContext;
         }
         else if (num10 >= 0x0)
         {
             reader.Seek(position + num10, SeekOrigin.Begin);
             ScriptCore.SavedTaskContext invalidSavedTaskContext = ReadTask(reader, persistReader);
             if (invalidSavedTaskContext == null)
             {
                 invalidSavedTaskContext = InvalidSavedTaskContext;
             }
             this.mSavedTaskContexts[k] = invalidSavedTaskContext;
         }
     }
 }
示例#32
0
        /*
    .method public hidebysig newslot virtual final 
            instance void  Read(class Sims3.SimIFace.FastStreamReader reader,
                                class Sims3.SimIFace.IPersistReader persistReader) cil managed
         * 
         * 
               object V_4,
               class [mscorlib]System.Type V_5,
               class [mscorlib]System.Reflection.MethodInfo V_6,
               object[] V_7)
      IL_0000:  ldarg.2
      IL_0001:  callvirt   instance object [SimIFace]Sims3.SimIFace.IPersistReader::ReadReference()
      IL_0006:  castclass  [mscorlib]System.Type
      IL_000b:  stloc.0
      IL_000c:  ldarg.1
      IL_000d:  callvirt   instance string [SimIFace]Sims3.SimIFace.FastStreamReader::ReadString()
      IL_0012:  stloc.1
      IL_0013:  ldarg.2
      IL_0014:  callvirt   instance object [SimIFace]Sims3.SimIFace.IPersistReader::ReadReference()
      IL_0019:  stloc.2
      IL_001a:  ldloc.0
      IL_001b:  brfalse.s  IL_0099

      IL_001d:  ldnull
      IL_001e:  stloc.3
      IL_001f:  ldloc.0
      IL_0020:  ldloc.1
      IL_0021:  ldc.i4.s   56
      IL_0023:  callvirt   instance class [mscorlib]System.Reflection.FieldInfo [mscorlib]System.Type::GetField(string,
                                                                                                                valuetype [mscorlib]System.Reflection.BindingFlags)
      IL_0028:  stloc.3
      IL_0029:  ldloc.3
      IL_002a:  brfalse.s  IL_0099

      IL_002c:  ldloc.3
      IL_002d:  callvirt   instance bool [mscorlib]System.Reflection.FieldInfo::get_IsStatic()
      IL_0032:  brfalse.s  IL_0099

      IL_0034:  ldloc.3
      IL_0035:  call       bool [SimIFace]Sims3.SimIFace.PersistStatic::IsFieldSerializable(class [mscorlib]System.Reflection.FieldInfo)
      IL_003a:  brfalse.s  IL_0099

      .try
      {
        IL_003c:  ldloc.3
        IL_003d:  ldnull
        IL_003e:  ldloc.2
        IL_003f:  callvirt   instance void [mscorlib]System.Reflection.FieldInfo::SetValue(object,
                                                                                           object)
        IL_0044:  ldloc.3
        IL_0045:  ldnull
        IL_0046:  callvirt   instance object [mscorlib]System.Reflection.FieldInfo::GetValue(object)
        IL_004b:  stloc.s    V_4
        IL_004d:  ldstr      "ScriptCore.ExceptionTrap, ScriptCore"
        IL_0052:  call       class [mscorlib]System.Type [mscorlib]System.Type::GetType(string)
        IL_0057:  stloc.s    V_5
        IL_0059:  ldloc.s    V_5
        IL_005b:  brfalse.s  IL_0094

        IL_005d:  ldloc.s    V_5
        IL_005f:  ldstr      "ExternalLoadReference"
        IL_0064:  ldc.i4.s   24
        IL_0066:  callvirt   instance class [mscorlib]System.Reflection.MethodInfo [mscorlib]System.Type::GetMethod(string,
                                                                                                                    valuetype [mscorlib]System.Reflection.BindingFlags)
        IL_006b:  stloc.s    V_6
        IL_006d:  ldloc.s    V_6
        IL_006f:  brfalse.s  IL_0094

        IL_0071:  ldloc.s    V_6
        IL_0073:  ldnull
        IL_0074:  ldc.i4.3
        IL_0075:  newarr     [mscorlib]System.Object
        IL_007a:  stloc.s    V_7
        IL_007c:  ldloc.s    V_7
        IL_007e:  ldc.i4.0
        IL_007f:  ldloc.2
        IL_0080:  stelem.ref
        IL_0081:  ldloc.s    V_7
        IL_0083:  ldc.i4.1
        IL_0084:  ldloc.s    V_4
        IL_0086:  stelem.ref
        IL_0087:  ldloc.s    V_7
        IL_0089:  ldc.i4.2
        IL_008a:  ldloc.3
        IL_008b:  stelem.ref
        IL_008c:  ldloc.s    V_7
        IL_008e:  callvirt   instance object [mscorlib]System.Reflection.MethodBase::Invoke(object,
                                                                                            object[])
        IL_0093:  pop
        IL_0094:  leave.s    IL_0099

      }  // end .try
      catch [mscorlib]System.ArgumentException 
      {
        IL_0096:  pop
        IL_0097:  leave.s    IL_0099

      }  // end handler
      IL_0099:  ret
         */
        public void Read(FastStreamReader reader, IPersistReader persistReader)
        {
            Type type = (Type)persistReader.ReadReference();
            string name = reader.ReadString();
            object obj2 = persistReader.ReadReference();
            if (type != null)
            {
                FieldInfo fieldInfo = null;
                fieldInfo = type.GetField(name, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static);
                if (((fieldInfo != null) && fieldInfo.IsStatic) && PersistStatic.IsFieldSerializable(fieldInfo))
                {
                    try
                    {
                        fieldInfo.SetValue(null, obj2);

                        object parent = fieldInfo.GetValue(null);

                        Type exceptionTrap = Type.GetType("ScriptCore.ExceptionTrap, ScriptCore");
                        if (exceptionTrap != null)
                        {
                            MethodInfo loadReference = exceptionTrap.GetMethod("ExternalLoadReference", BindingFlags.Public | BindingFlags.Static);
                            if (loadReference != null)
                            {
                                loadReference.Invoke(null, new object[] { obj2, parent, fieldInfo });
                            }
                        }
                    }
                    catch (ArgumentException)
                    {
                    }
                }
            }
        }