Beispiel #1
0
        private object DeserializeCustom(StreamBuffer din, byte customTypeCode)
        {
            short      num        = this.DeserializeShort(din);
            CustomType customType = default(CustomType);

            if (Protocol.CodeDict.TryGetValue(customTypeCode, out customType))
            {
                if (customType.DeserializeStreamFunction == null)
                {
                    byte[] array = new byte[num];
                    din.Read(array, 0, num);
                    return(customType.DeserializeFunction(array));
                }
                int    position = din.Position;
                object result   = customType.DeserializeStreamFunction(din, num);
                int    num2     = din.Position - position;
                if (num2 != num)
                {
                    din.Position = position + num;
                }
                return(result);
            }
            byte[] array2 = new byte[num];
            din.Read(array2, 0, num);
            return(array2);
        }
Beispiel #2
0
        private Array DeserializeArray(StreamBuffer din)
        {
            short num   = this.DeserializeShort(din);
            byte  b     = din.ReadByte();
            Array array = null;

            switch (b)
            {
            case 121:
            {
                Array array3 = this.DeserializeArray(din);
                Type  type   = array3.GetType();
                array = Array.CreateInstance(type, num);
                array.SetValue(array3, 0);
                for (short num4 = 1; num4 < num; num4 = (short)(num4 + 1))
                {
                    array3 = this.DeserializeArray(din);
                    array.SetValue(array3, num4);
                }
                goto IL_0226;
            }

            case 120:
                array = Array.CreateInstance(typeof(byte[]), num);
                for (short num5 = 0; num5 < num; num5 = (short)(num5 + 1))
                {
                    Array value = this.DeserializeByteArray(din, -1);
                    array.SetValue(value, num5);
                }
                goto IL_0226;

            case 98:
                array = this.DeserializeByteArray(din, num);
                goto IL_0226;

            case 105:
                array = this.DeserializeIntArray(din, num);
                goto IL_0226;

            case 99:
            {
                byte       b2         = din.ReadByte();
                CustomType customType = default(CustomType);
                if (Protocol.CodeDict.TryGetValue(b2, out customType))
                {
                    array = Array.CreateInstance(customType.Type, num);
                    for (int i = 0; i < num; i++)
                    {
                        short num3 = this.DeserializeShort(din);
                        if (customType.DeserializeStreamFunction == null)
                        {
                            byte[] array2 = new byte[num3];
                            din.Read(array2, 0, num3);
                            array.SetValue(customType.DeserializeFunction(array2), i);
                        }
                        else
                        {
                            array.SetValue(customType.DeserializeStreamFunction(din, num3), i);
                        }
                    }
                    goto IL_0226;
                }
                throw new Exception("Cannot find deserializer for custom type: " + b2);
            }

            case 68:
            {
                Array result = null;
                this.DeserializeDictionaryArray(din, num, out result);
                return(result);
            }

            default:
            {
                array = this.CreateArrayByType(b, num);
                for (short num2 = 0; num2 < num; num2 = (short)(num2 + 1))
                {
                    array.SetValue(this.Deserialize(din, b), num2);
                }
                goto IL_0226;
            }
IL_0226:
                return(array);
            }
        }