Exemple #1
0
    protected override object DoDeserializeComplicatedType(Type type, byte[] buff, ref int offset)
    {
        int    num  = ByteConverter.Parse <int>(buff, ref offset);
        object obj2 = null;

        if (num > -1)
        {
            obj2 = Activator.CreateInstance(type);
            Class138 class2 = this.method_0(type);
            for (int i = 0; i < class2.method_0().Length; i++)
            {
                object val = base.DoDeserialize(class2.method_0()[i].FieldType, buff, ref offset);
                ReflectionHelper.SetFieldValue(obj2, class2.method_0()[i].Name, val);
            }
        }
        return(obj2);
    }
Exemple #2
0
 protected override void DoSerializeComplicatedType(Type type, object obj, MemoryStream stream)
 {
     if (obj == null)
     {
         byte[] buffer3 = ByteConverter.ToBytes <int>(-1);
         stream.Write(buffer3, 0, buffer3.Length);
     }
     else
     {
         Class138     class2  = this.method_0(type);
         MemoryStream stream2 = new MemoryStream();
         for (int i = 0; i < class2.method_0().Length; i++)
         {
             object fieldValue = ReflectionHelper.GetFieldValue(obj, class2.method_0()[i].Name);
             base.DoSerialize(stream2, class2.method_0()[i].FieldType, fieldValue);
         }
         byte[] buffer  = stream2.ToArray();
         byte[] buffer2 = ByteConverter.ToBytes <int>(buffer.Length);
         stream.Write(buffer2, 0, buffer2.Length);
         stream.Write(buffer, 0, buffer.Length);
     }
 }