Example #1
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)
                    {
                    }
                }
            }
        }
Example #2
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)
                    {
                    }
                }
            }
        }