Example #1
0
        public object ReadValue()
        {
            this.Read(this.buffer, 2);
            StreamPropertyType propId = (StreamPropertyType)BitConverter.ToInt16(this.buffer, 0);

            return(this.ReadRawValue(propId));
        }
 public static void Serialize(StreamPropertyType propId, object value, byte[] buffer, ref int offset)
 {
     if (buffer == null || offset > buffer.Length)
     {
         throw new ArgumentException("buffer");
     }
     offset += ExBitConverter.Write((short)propId, buffer, offset);
     PropertyStreamWriter.WriteValue(propId, value, buffer, ref offset);
 }
        private static void WriteMultiValuedProperty <T>(StreamPropertyType propId, MultiValuedProperty <T> list, byte[] buffer, ref int offset)
        {
            int num = (list != null) ? list.Count : 0;

            offset += ExBitConverter.Write(num, buffer, offset);
            for (int i = 0; i < num; i++)
            {
                PropertyStreamWriter.WriteValue(propId & ~StreamPropertyType.MultiValuedProperty, list[i], buffer, ref offset);
            }
        }
        private static void WriteArray <T>(StreamPropertyType propId, T[] array, byte[] buffer, ref int offset)
        {
            int num = (array != null) ? array.Length : 0;

            offset += ExBitConverter.Write(num, buffer, offset);
            for (int i = 0; i < num; i++)
            {
                PropertyStreamWriter.WriteValue(propId & ~StreamPropertyType.Array, array[i], buffer, ref offset);
            }
        }
Example #5
0
        protected void ReadMultiValuedProperty <T>(StreamPropertyType propId, out List <T> list)
        {
            this.Read(this.buffer, 4);
            int num = BitConverter.ToInt32(this.buffer, 0);

            list = new List <T>(num);
            for (int i = 0; i < num; i++)
            {
                object obj = this.ReadRawValue(propId & ~StreamPropertyType.MultiValuedProperty);
                list.Add((T)((object)obj));
            }
        }
Example #6
0
        protected void ReadArray <T>(StreamPropertyType propId, out T[] array)
        {
            this.Read(this.buffer, 4);
            int num = BitConverter.ToInt32(this.buffer, 0);

            array = new T[num];
            for (int i = 0; i < array.Length; i++)
            {
                object obj = this.ReadRawValue(propId & ~StreamPropertyType.Array);
                array[i] = (T)((object)obj);
            }
        }
        public static void WritePropertyKeyValue(string propertyName, StreamPropertyType valueType, object value, ref byte[] bytes, ref int offset)
        {
            int num = PropertyStreamWriter.SizeOf(StreamPropertyType.String, propertyName) + PropertyStreamWriter.SizeOf(valueType, value);

            if (offset + num >= bytes.Length)
            {
                int    num2  = (offset + num > bytes.Length * 2) ? (offset + num + bytes.Length) : (bytes.Length * 2);
                byte[] array = new byte[num2];
                Array.Copy(bytes, array, bytes.Length);
                bytes = array;
            }
            PropertyStreamWriter.Serialize(StreamPropertyType.String, propertyName, bytes, ref offset);
            PropertyStreamWriter.Serialize(valueType, value, bytes, ref offset);
        }
Example #8
0
        protected virtual object ReadRawValue(StreamPropertyType propId)
        {
            if (propId <= (StreamPropertyType.Null | StreamPropertyType.UInt32 | StreamPropertyType.DateTime | StreamPropertyType.List))
            {
                switch (propId)
                {
                case StreamPropertyType.Null:
                    return(null);

                case StreamPropertyType.Bool:
                    this.Read(this.buffer, 1);
                    return(this.buffer[0] == 1);

                case StreamPropertyType.Byte:
                    this.Read(this.buffer, 1);
                    return(this.buffer[0]);

                case StreamPropertyType.SByte:
                    this.Read(this.buffer, 1);
                    return((sbyte)this.buffer[0]);

                case StreamPropertyType.Int16:
                    this.Read(this.buffer, 2);
                    return(BitConverter.ToInt16(this.buffer, 0));

                case StreamPropertyType.UInt16:
                    this.Read(this.buffer, 2);
                    return(BitConverter.ToUInt16(this.buffer, 0));

                case StreamPropertyType.Int32:
                    this.Read(this.buffer, 4);
                    return(BitConverter.ToInt32(this.buffer, 0));

                case StreamPropertyType.UInt32:
                    this.Read(this.buffer, 4);
                    return(BitConverter.ToUInt32(this.buffer, 0));

                case StreamPropertyType.Int64:
                    this.Read(this.buffer, 8);
                    return(BitConverter.ToInt64(this.buffer, 0));

                case StreamPropertyType.UInt64:
                    this.Read(this.buffer, 8);
                    return(BitConverter.ToUInt64(this.buffer, 0));

                case StreamPropertyType.Single:
                    this.Read(this.buffer, 4);
                    return(BitConverter.ToSingle(this.buffer, 0));

                case StreamPropertyType.Double:
                    this.Read(this.buffer, 8);
                    return(BitConverter.ToDouble(this.buffer, 0));

                case StreamPropertyType.Decimal:
                {
                    this.Read(this.buffer, 16);
                    int[] array = new int[4];
                    for (int i = 0; i < 4; i++)
                    {
                        array[i] = BitConverter.ToInt32(this.buffer, i * 4);
                    }
                    return(new decimal(array));
                }

                case StreamPropertyType.Char:
                {
                    char[] array2 = (char[])this.ReadRawValue(StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.Array);
                    if (array2 == null || array2.Length != 1)
                    {
                        throw new FormatException("Extended property stream. Invalid character content.");
                    }
                    return(array2[0]);
                }

                case StreamPropertyType.String:
                {
                    this.Read(this.buffer, 4);
                    int num = BitConverter.ToInt32(this.buffer, 0);
                    if (num == 0)
                    {
                        return(string.Empty);
                    }
                    if (num > this.buffer.Length)
                    {
                        byte[] bytes = new byte[num];
                        this.Read(bytes, num);
                        return(Encoding.UTF8.GetString(bytes, 0, num));
                    }
                    this.Read(this.buffer, num);
                    return(Encoding.UTF8.GetString(this.buffer, 0, num));
                }

                case StreamPropertyType.DateTime:
                {
                    this.Read(this.buffer, 8);
                    long fileTime = BitConverter.ToInt64(this.buffer, 0);
                    return(DateTime.FromFileTimeUtc(fileTime));
                }

                case StreamPropertyType.Guid:
                    this.Read(this.buffer, 16);
                    return(ExBitConverter.ReadGuid(this.buffer, 0));

                case StreamPropertyType.IPAddress:
                {
                    this.Read(this.buffer, 16);
                    IPvxAddress address = new IPvxAddress(BitConverter.ToUInt64(this.buffer, 8), BitConverter.ToUInt64(this.buffer, 0));
                    return(address);
                }

                case StreamPropertyType.IPEndPoint:
                {
                    IPAddress ipaddress = (IPAddress)this.ReadRawValue(StreamPropertyType.IPAddress);
                    ushort    num2      = (ushort)this.ReadRawValue(StreamPropertyType.UInt16);
                    if (ipaddress != IPAddress.None || num2 != 0)
                    {
                        return(new IPEndPoint(ipaddress, (int)num2));
                    }
                    return(null);
                }

                case StreamPropertyType.RoutingAddress:
                case StreamPropertyType.ADObjectId:
                case StreamPropertyType.RecipientType:
                case StreamPropertyType.ADObjectIdUTF8:
                case StreamPropertyType.ADObjectIdWithString:
                case StreamPropertyType.ProxyAddress:
                    break;

                default:
                    switch (propId)
                    {
                    case StreamPropertyType.Bool | StreamPropertyType.Array:
                    {
                        bool[] result;
                        this.ReadArray <bool>(propId, out result);
                        return(result);
                    }

                    case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.Array:
                    {
                        byte[] result2;
                        this.ReadArray <byte>(propId, out result2);
                        return(result2);
                    }

                    case StreamPropertyType.SByte | StreamPropertyType.Array:
                    {
                        sbyte[] result3;
                        this.ReadArray <sbyte>(propId, out result3);
                        return(result3);
                    }

                    case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.Array:
                    {
                        short[] result4;
                        this.ReadArray <short>(propId, out result4);
                        return(result4);
                    }

                    case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.Array:
                    {
                        ushort[] result5;
                        this.ReadArray <ushort>(propId, out result5);
                        return(result5);
                    }

                    case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.Array:
                    {
                        int[] result6;
                        this.ReadArray <int>(propId, out result6);
                        return(result6);
                    }

                    case StreamPropertyType.UInt32 | StreamPropertyType.Array:
                    {
                        uint[] result7;
                        this.ReadArray <uint>(propId, out result7);
                        return(result7);
                    }

                    case StreamPropertyType.Null | StreamPropertyType.UInt32 | StreamPropertyType.Array:
                    {
                        long[] result8;
                        this.ReadArray <long>(propId, out result8);
                        return(result8);
                    }

                    case StreamPropertyType.Bool | StreamPropertyType.UInt32 | StreamPropertyType.Array:
                    {
                        ulong[] result9;
                        this.ReadArray <ulong>(propId, out result9);
                        return(result9);
                    }

                    case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.UInt32 | StreamPropertyType.Array:
                    {
                        float[] result10;
                        this.ReadArray <float>(propId, out result10);
                        return(result10);
                    }

                    case StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.Array:
                    {
                        double[] result11;
                        this.ReadArray <double>(propId, out result11);
                        return(result11);
                    }

                    case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.Array:
                    {
                        decimal[] result12;
                        this.ReadArray <decimal>(propId, out result12);
                        return(result12);
                    }

                    case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.Array:
                    {
                        this.Read(this.buffer, 4);
                        int num3 = BitConverter.ToInt32(this.buffer, 0);
                        if (num3 == 0)
                        {
                            return(new char[0]);
                        }
                        if (num3 > this.buffer.Length)
                        {
                            byte[] bytes2 = new byte[num3];
                            this.Read(bytes2, num3);
                            return(Encoding.UTF8.GetChars(bytes2));
                        }
                        this.Read(this.buffer, num3);
                        return(Encoding.UTF8.GetChars(this.buffer, 0, num3));
                    }

                    case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.Array:
                    {
                        string[] result13;
                        this.ReadArray <string>(propId, out result13);
                        return(result13);
                    }

                    case StreamPropertyType.DateTime | StreamPropertyType.Array:
                    {
                        DateTime[] result14;
                        this.ReadArray <DateTime>(propId, out result14);
                        return(result14);
                    }

                    case StreamPropertyType.Null | StreamPropertyType.DateTime | StreamPropertyType.Array:
                    {
                        Guid[] result15;
                        this.ReadArray <Guid>(propId, out result15);
                        return(result15);
                    }

                    case StreamPropertyType.Bool | StreamPropertyType.DateTime | StreamPropertyType.Array:
                    {
                        IPAddress[] result16;
                        this.ReadArray <IPAddress>(propId, out result16);
                        return(result16);
                    }

                    case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.DateTime | StreamPropertyType.Array:
                    {
                        IPEndPoint[] result17;
                        this.ReadArray <IPEndPoint>(propId, out result17);
                        return(result17);
                    }

                    case StreamPropertyType.SByte | StreamPropertyType.DateTime | StreamPropertyType.Array:
                    case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.DateTime | StreamPropertyType.Array:
                    case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.DateTime | StreamPropertyType.Array:
                    case StreamPropertyType.UInt32 | StreamPropertyType.DateTime | StreamPropertyType.Array:
                    case StreamPropertyType.Null | StreamPropertyType.UInt32 | StreamPropertyType.DateTime | StreamPropertyType.Array:
                        break;

                    case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.DateTime | StreamPropertyType.Array:
                        goto IL_8D3;

                    default:
                        switch (propId)
                        {
                        case StreamPropertyType.Bool | StreamPropertyType.List:
                        {
                            List <bool> result18;
                            this.ReadList <bool>(propId, out result18);
                            return(result18);
                        }

                        case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.List:
                        {
                            List <byte> result19;
                            this.ReadList <byte>(propId, out result19);
                            return(result19);
                        }

                        case StreamPropertyType.SByte | StreamPropertyType.List:
                        {
                            List <sbyte> result20;
                            this.ReadList <sbyte>(propId, out result20);
                            return(result20);
                        }

                        case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.List:
                        {
                            List <short> result21;
                            this.ReadList <short>(propId, out result21);
                            return(result21);
                        }

                        case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.List:
                        {
                            List <ushort> result22;
                            this.ReadList <ushort>(propId, out result22);
                            return(result22);
                        }

                        case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.List:
                        {
                            List <int> result23;
                            this.ReadList <int>(propId, out result23);
                            return(result23);
                        }

                        case StreamPropertyType.UInt32 | StreamPropertyType.List:
                        {
                            List <uint> result24;
                            this.ReadList <uint>(propId, out result24);
                            return(result24);
                        }

                        case StreamPropertyType.Null | StreamPropertyType.UInt32 | StreamPropertyType.List:
                        {
                            List <long> result25;
                            this.ReadList <long>(propId, out result25);
                            return(result25);
                        }

                        case StreamPropertyType.Bool | StreamPropertyType.UInt32 | StreamPropertyType.List:
                        {
                            List <ulong> result26;
                            this.ReadList <ulong>(propId, out result26);
                            return(result26);
                        }

                        case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.UInt32 | StreamPropertyType.List:
                        {
                            List <float> result27;
                            this.ReadList <float>(propId, out result27);
                            return(result27);
                        }

                        case StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.List:
                        {
                            List <double> result28;
                            this.ReadList <double>(propId, out result28);
                            return(result28);
                        }

                        case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.List:
                        {
                            List <decimal> result29;
                            this.ReadList <decimal>(propId, out result29);
                            return(result29);
                        }

                        case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.List:
                        {
                            this.Read(this.buffer, 4);
                            int num4 = BitConverter.ToInt32(this.buffer, 0);
                            if (num4 == 0)
                            {
                                return(new char[0]);
                            }
                            if (num4 > this.buffer.Length)
                            {
                                byte[] bytes3 = new byte[num4];
                                this.Read(bytes3, num4);
                                return(new List <char>(Encoding.UTF8.GetChars(bytes3)));
                            }
                            this.Read(this.buffer, num4);
                            return(new List <char>(Encoding.UTF8.GetChars(this.buffer, 0, num4)));
                        }

                        case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.List:
                        {
                            List <string> result30;
                            this.ReadList <string>(propId, out result30);
                            return(result30);
                        }

                        case StreamPropertyType.DateTime | StreamPropertyType.List:
                        {
                            List <DateTime> result31;
                            this.ReadList <DateTime>(propId, out result31);
                            return(result31);
                        }

                        case StreamPropertyType.Null | StreamPropertyType.DateTime | StreamPropertyType.List:
                        {
                            List <Guid> result32;
                            this.ReadList <Guid>(propId, out result32);
                            return(result32);
                        }

                        case StreamPropertyType.Bool | StreamPropertyType.DateTime | StreamPropertyType.List:
                        {
                            List <IPAddress> result33;
                            this.ReadList <IPAddress>(propId, out result33);
                            return(result33);
                        }

                        case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.DateTime | StreamPropertyType.List:
                        {
                            List <IPEndPoint> result34;
                            this.ReadList <IPEndPoint>(propId, out result34);
                            return(result34);
                        }

                        case StreamPropertyType.SByte | StreamPropertyType.DateTime | StreamPropertyType.List:
                        case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.DateTime | StreamPropertyType.List:
                        case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.DateTime | StreamPropertyType.List:
                        case StreamPropertyType.UInt32 | StreamPropertyType.DateTime | StreamPropertyType.List:
                        case StreamPropertyType.Null | StreamPropertyType.UInt32 | StreamPropertyType.DateTime | StreamPropertyType.List:
                            break;

                        case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.DateTime | StreamPropertyType.List:
                            goto IL_8D3;

                        default:
                            goto IL_8D3;
                        }
                        break;
                    }
                    break;
                }
            }
            else
            {
                if (propId == (StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.Array | StreamPropertyType.List))
                {
                    List <byte[]> result35;
                    this.ReadList <byte[]>(propId, out result35);
                    return(result35);
                }
                switch (propId)
                {
                case StreamPropertyType.Bool | StreamPropertyType.MultiValuedProperty:
                {
                    List <bool> result36;
                    this.ReadMultiValuedProperty <bool>(propId, out result36);
                    return(result36);
                }

                case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.MultiValuedProperty:
                {
                    List <byte> result37;
                    this.ReadMultiValuedProperty <byte>(propId, out result37);
                    return(result37);
                }

                case StreamPropertyType.SByte | StreamPropertyType.MultiValuedProperty:
                {
                    List <sbyte> result38;
                    this.ReadMultiValuedProperty <sbyte>(propId, out result38);
                    return(result38);
                }

                case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.MultiValuedProperty:
                {
                    List <short> result39;
                    this.ReadMultiValuedProperty <short>(propId, out result39);
                    return(result39);
                }

                case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.MultiValuedProperty:
                {
                    List <ushort> result40;
                    this.ReadMultiValuedProperty <ushort>(propId, out result40);
                    return(result40);
                }

                case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.MultiValuedProperty:
                {
                    List <int> result41;
                    this.ReadMultiValuedProperty <int>(propId, out result41);
                    return(result41);
                }

                case StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty:
                {
                    List <uint> result42;
                    this.ReadMultiValuedProperty <uint>(propId, out result42);
                    return(result42);
                }

                case StreamPropertyType.Null | StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty:
                {
                    List <long> result43;
                    this.ReadMultiValuedProperty <long>(propId, out result43);
                    return(result43);
                }

                case StreamPropertyType.Bool | StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty:
                {
                    List <ulong> result44;
                    this.ReadMultiValuedProperty <ulong>(propId, out result44);
                    return(result44);
                }

                case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty:
                {
                    List <float> result45;
                    this.ReadMultiValuedProperty <float>(propId, out result45);
                    return(result45);
                }

                case StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty:
                {
                    List <double> result46;
                    this.ReadMultiValuedProperty <double>(propId, out result46);
                    return(result46);
                }

                case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty:
                {
                    List <decimal> result47;
                    this.ReadMultiValuedProperty <decimal>(propId, out result47);
                    return(result47);
                }

                case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty:
                {
                    this.Read(this.buffer, 4);
                    int num5 = BitConverter.ToInt32(this.buffer, 0);
                    if (num5 == 0)
                    {
                        return(new char[0]);
                    }
                    if (num5 > this.buffer.Length)
                    {
                        byte[] bytes4 = new byte[num5];
                        this.Read(bytes4, num5);
                        return(new List <char>(Encoding.UTF8.GetChars(bytes4)));
                    }
                    this.Read(this.buffer, num5);
                    return(new List <char>(Encoding.UTF8.GetChars(this.buffer, 0, num5)));
                }

                case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty:
                {
                    List <string> result48;
                    this.ReadMultiValuedProperty <string>(propId, out result48);
                    return(result48);
                }

                case StreamPropertyType.DateTime | StreamPropertyType.MultiValuedProperty:
                {
                    List <DateTime> result49;
                    this.ReadMultiValuedProperty <DateTime>(propId, out result49);
                    return(result49);
                }

                case StreamPropertyType.Null | StreamPropertyType.DateTime | StreamPropertyType.MultiValuedProperty:
                {
                    List <Guid> result50;
                    this.ReadMultiValuedProperty <Guid>(propId, out result50);
                    return(result50);
                }

                case StreamPropertyType.Bool | StreamPropertyType.DateTime | StreamPropertyType.MultiValuedProperty:
                {
                    List <IPAddress> result51;
                    this.ReadMultiValuedProperty <IPAddress>(propId, out result51);
                    return(result51);
                }

                case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.DateTime | StreamPropertyType.MultiValuedProperty:
                {
                    List <IPEndPoint> result52;
                    this.ReadMultiValuedProperty <IPEndPoint>(propId, out result52);
                    return(result52);
                }

                case StreamPropertyType.SByte | StreamPropertyType.DateTime | StreamPropertyType.MultiValuedProperty:
                case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.DateTime | StreamPropertyType.MultiValuedProperty:
                case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.DateTime | StreamPropertyType.MultiValuedProperty:
                case StreamPropertyType.UInt32 | StreamPropertyType.DateTime | StreamPropertyType.MultiValuedProperty:
                case StreamPropertyType.Null | StreamPropertyType.UInt32 | StreamPropertyType.DateTime | StreamPropertyType.MultiValuedProperty:
                    break;

                case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.DateTime | StreamPropertyType.MultiValuedProperty:
                    goto IL_8D3;

                default:
                {
                    if (propId != (StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.Array | StreamPropertyType.MultiValuedProperty))
                    {
                        goto IL_8D3;
                    }
                    List <byte[]> result53;
                    this.ReadMultiValuedProperty <byte[]>(propId, out result53);
                    return(result53);
                }
                }
            }
            throw new InvalidOperationException(string.Format("The property type {0} is not supported by PropertyStreamReader, but may be supported by a subclass", propId));
IL_8D3:
            throw new FormatException("Invalid value data " + propId);
        }
        public static void WriteValue(StreamPropertyType propId, object value, byte[] buffer, ref int offset)
        {
            if (buffer == null || offset > buffer.Length)
            {
                throw new ArgumentException("buffer");
            }
            if (propId <= (StreamPropertyType.Null | StreamPropertyType.UInt32 | StreamPropertyType.DateTime | StreamPropertyType.List))
            {
                switch (propId)
                {
                case StreamPropertyType.Null:
                    return;

                case StreamPropertyType.Bool:
                    buffer[offset++] = (((bool)value) ? 1 : 0);
                    return;

                case StreamPropertyType.Byte:
                    buffer[offset++] = (byte)value;
                    return;

                case StreamPropertyType.SByte:
                {
                    sbyte b = (sbyte)value;
                    buffer[offset++] = (byte)b;
                    return;
                }

                case StreamPropertyType.Int16:
                    offset += ExBitConverter.Write((short)value, buffer, offset);
                    return;

                case StreamPropertyType.UInt16:
                    offset += ExBitConverter.Write((ushort)value, buffer, offset);
                    return;

                case StreamPropertyType.Int32:
                    offset += ExBitConverter.Write((int)value, buffer, offset);
                    return;

                case StreamPropertyType.UInt32:
                    offset += ExBitConverter.Write((uint)value, buffer, offset);
                    return;

                case StreamPropertyType.Int64:
                    offset += ExBitConverter.Write((long)value, buffer, offset);
                    return;

                case StreamPropertyType.UInt64:
                    offset += ExBitConverter.Write((ulong)value, buffer, offset);
                    return;

                case StreamPropertyType.Single:
                    offset += ExBitConverter.Write((float)value, buffer, offset);
                    return;

                case StreamPropertyType.Double:
                    offset += ExBitConverter.Write((double)value, buffer, offset);
                    return;

                case StreamPropertyType.Decimal:
                {
                    decimal d    = (decimal)value;
                    int[]   bits = decimal.GetBits(d);
                    for (int i = 0; i < bits.Length; i++)
                    {
                        offset += ExBitConverter.Write(bits[i], buffer, offset);
                    }
                    return;
                }

                case StreamPropertyType.Char:
                    value = new char[]
                    {
                        (char)value
                    };
                    break;

                case StreamPropertyType.String:
                {
                    int    num  = 0;
                    string text = (string)value;
                    if (!string.IsNullOrEmpty(text))
                    {
                        num = Encoding.UTF8.GetBytes(text, 0, text.Length, buffer, offset + 4);
                    }
                    offset += ExBitConverter.Write(num, buffer, offset);
                    offset += num;
                    return;
                }

                case StreamPropertyType.DateTime:
                {
                    DateTime dateTime = (DateTime)value;
                    offset += ExBitConverter.Write(dateTime.ToFileTimeUtc(), buffer, offset);
                    return;
                }

                case StreamPropertyType.Guid:
                    offset += ExBitConverter.Write((Guid)value, buffer, offset);
                    return;

                case StreamPropertyType.IPAddress:
                {
                    IPvxAddress pvxAddress = new IPvxAddress((value == null) ? IPAddress.None : ((IPAddress)value));
                    long        value2     = (long)((ulong)((uint)pvxAddress));
                    offset += ExBitConverter.Write(value2, buffer, offset);
                    value2  = (long)((ulong)((uint)(pvxAddress >> 64)));
                    offset += ExBitConverter.Write(value2, buffer, offset);
                    return;
                }

                case StreamPropertyType.IPEndPoint:
                {
                    if (value == null)
                    {
                        PropertyStreamWriter.WriteValue(StreamPropertyType.IPAddress, IPAddress.None, buffer, ref offset);
                        PropertyStreamWriter.WriteValue(StreamPropertyType.UInt16, 0, buffer, ref offset);
                        return;
                    }
                    IPEndPoint ipendPoint = (IPEndPoint)value;
                    PropertyStreamWriter.WriteValue(StreamPropertyType.IPAddress, ipendPoint.Address, buffer, ref offset);
                    PropertyStreamWriter.WriteValue(StreamPropertyType.UInt16, (ushort)ipendPoint.Port, buffer, ref offset);
                    return;
                }

                case StreamPropertyType.RoutingAddress:
                case StreamPropertyType.ADObjectId:
                case StreamPropertyType.RecipientType:
                case StreamPropertyType.ADObjectIdUTF8:
                case StreamPropertyType.ADObjectIdWithString:
                case StreamPropertyType.ProxyAddress:
                    goto IL_808;

                default:
                    switch (propId)
                    {
                    case StreamPropertyType.Bool | StreamPropertyType.Array:
                        PropertyStreamWriter.WriteArray <bool>(propId, (bool[])value, buffer, ref offset);
                        return;

                    case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.Array:
                    {
                        byte[] array = (byte[])value;
                        offset += ExBitConverter.Write(array.Length, buffer, offset);
                        if (array.Length != 0)
                        {
                            Array.Copy(array, 0, buffer, offset, array.Length);
                            offset += array.Length;
                            return;
                        }
                        return;
                    }

                    case StreamPropertyType.SByte | StreamPropertyType.Array:
                        PropertyStreamWriter.WriteArray <sbyte>(propId, (sbyte[])value, buffer, ref offset);
                        return;

                    case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.Array:
                        PropertyStreamWriter.WriteArray <short>(propId, (short[])value, buffer, ref offset);
                        return;

                    case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.Array:
                        PropertyStreamWriter.WriteArray <ushort>(propId, (ushort[])value, buffer, ref offset);
                        return;

                    case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.Array:
                        PropertyStreamWriter.WriteArray <int>(propId, (int[])value, buffer, ref offset);
                        return;

                    case StreamPropertyType.UInt32 | StreamPropertyType.Array:
                        PropertyStreamWriter.WriteArray <uint>(propId, (uint[])value, buffer, ref offset);
                        return;

                    case StreamPropertyType.Null | StreamPropertyType.UInt32 | StreamPropertyType.Array:
                        PropertyStreamWriter.WriteArray <long>(propId, (long[])value, buffer, ref offset);
                        return;

                    case StreamPropertyType.Bool | StreamPropertyType.UInt32 | StreamPropertyType.Array:
                        PropertyStreamWriter.WriteArray <ulong>(propId, (ulong[])value, buffer, ref offset);
                        return;

                    case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.UInt32 | StreamPropertyType.Array:
                        PropertyStreamWriter.WriteArray <float>(propId, (float[])value, buffer, ref offset);
                        return;

                    case StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.Array:
                        PropertyStreamWriter.WriteArray <double>(propId, (double[])value, buffer, ref offset);
                        return;

                    case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.Array:
                        PropertyStreamWriter.WriteArray <decimal>(propId, (decimal[])value, buffer, ref offset);
                        return;

                    case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.Array:
                        break;

                    case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.Array:
                        PropertyStreamWriter.WriteArray <string>(propId, (string[])value, buffer, ref offset);
                        return;

                    case StreamPropertyType.DateTime | StreamPropertyType.Array:
                        PropertyStreamWriter.WriteArray <DateTime>(propId, (DateTime[])value, buffer, ref offset);
                        return;

                    case StreamPropertyType.Null | StreamPropertyType.DateTime | StreamPropertyType.Array:
                        PropertyStreamWriter.WriteArray <Guid>(propId, (Guid[])value, buffer, ref offset);
                        return;

                    case StreamPropertyType.Bool | StreamPropertyType.DateTime | StreamPropertyType.Array:
                        PropertyStreamWriter.WriteArray <IPAddress>(propId, (IPAddress[])value, buffer, ref offset);
                        return;

                    case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.DateTime | StreamPropertyType.Array:
                        PropertyStreamWriter.WriteArray <IPEndPoint>(propId, (IPEndPoint[])value, buffer, ref offset);
                        return;

                    case StreamPropertyType.SByte | StreamPropertyType.DateTime | StreamPropertyType.Array:
                    case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.DateTime | StreamPropertyType.Array:
                    case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.DateTime | StreamPropertyType.Array:
                    case StreamPropertyType.UInt32 | StreamPropertyType.DateTime | StreamPropertyType.Array:
                    case StreamPropertyType.Null | StreamPropertyType.UInt32 | StreamPropertyType.DateTime | StreamPropertyType.Array:
                        goto IL_808;

                    case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.DateTime | StreamPropertyType.Array:
                        return;

                    default:
                        switch (propId)
                        {
                        case StreamPropertyType.Bool | StreamPropertyType.List:
                            PropertyStreamWriter.WriteList <bool>(propId, (List <bool>)value, buffer, ref offset);
                            return;

                        case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.List:
                            PropertyStreamWriter.WriteList <byte>(propId, (List <byte>)value, buffer, ref offset);
                            return;

                        case StreamPropertyType.SByte | StreamPropertyType.List:
                            PropertyStreamWriter.WriteList <sbyte>(propId, (List <sbyte>)value, buffer, ref offset);
                            return;

                        case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.List:
                            PropertyStreamWriter.WriteList <short>(propId, (List <short>)value, buffer, ref offset);
                            return;

                        case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.List:
                            PropertyStreamWriter.WriteList <ushort>(propId, (List <ushort>)value, buffer, ref offset);
                            return;

                        case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.List:
                            PropertyStreamWriter.WriteList <int>(propId, (List <int>)value, buffer, ref offset);
                            return;

                        case StreamPropertyType.UInt32 | StreamPropertyType.List:
                            PropertyStreamWriter.WriteList <uint>(propId, (List <uint>)value, buffer, ref offset);
                            return;

                        case StreamPropertyType.Null | StreamPropertyType.UInt32 | StreamPropertyType.List:
                            PropertyStreamWriter.WriteList <long>(propId, (List <long>)value, buffer, ref offset);
                            return;

                        case StreamPropertyType.Bool | StreamPropertyType.UInt32 | StreamPropertyType.List:
                            PropertyStreamWriter.WriteList <ulong>(propId, (List <ulong>)value, buffer, ref offset);
                            return;

                        case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.UInt32 | StreamPropertyType.List:
                            PropertyStreamWriter.WriteList <float>(propId, (List <float>)value, buffer, ref offset);
                            return;

                        case StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.List:
                            PropertyStreamWriter.WriteList <double>(propId, (List <double>)value, buffer, ref offset);
                            return;

                        case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.List:
                            PropertyStreamWriter.WriteList <decimal>(propId, (List <decimal>)value, buffer, ref offset);
                            return;

                        case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.List:
                        {
                            char[] value3 = (value != null) ? ((List <char>)value).ToArray() : null;
                            PropertyStreamWriter.WriteValue(StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.Array, value3, buffer, ref offset);
                            return;
                        }

                        case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.List:
                            PropertyStreamWriter.WriteList <string>(propId, (List <string>)value, buffer, ref offset);
                            return;

                        case StreamPropertyType.DateTime | StreamPropertyType.List:
                            PropertyStreamWriter.WriteList <DateTime>(propId, (List <DateTime>)value, buffer, ref offset);
                            return;

                        case StreamPropertyType.Null | StreamPropertyType.DateTime | StreamPropertyType.List:
                            PropertyStreamWriter.WriteList <Guid>(propId, (List <Guid>)value, buffer, ref offset);
                            return;

                        case StreamPropertyType.Bool | StreamPropertyType.DateTime | StreamPropertyType.List:
                            PropertyStreamWriter.WriteList <IPAddress>(propId, (List <IPAddress>)value, buffer, ref offset);
                            return;

                        case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.DateTime | StreamPropertyType.List:
                            PropertyStreamWriter.WriteList <IPEndPoint>(propId, (List <IPEndPoint>)value, buffer, ref offset);
                            return;

                        case StreamPropertyType.SByte | StreamPropertyType.DateTime | StreamPropertyType.List:
                        case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.DateTime | StreamPropertyType.List:
                        case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.DateTime | StreamPropertyType.List:
                        case StreamPropertyType.UInt32 | StreamPropertyType.DateTime | StreamPropertyType.List:
                        case StreamPropertyType.Null | StreamPropertyType.UInt32 | StreamPropertyType.DateTime | StreamPropertyType.List:
                            goto IL_808;

                        case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.DateTime | StreamPropertyType.List:
                            return;

                        default:
                            return;
                        }
                        break;
                    }
                    break;
                }
                int num2 = 0;
                if (value != null)
                {
                    char[] array2 = (char[])value;
                    if (array2.Length != 0)
                    {
                        num2 = Encoding.UTF8.GetBytes(array2, 0, array2.Length, buffer, offset + 4);
                    }
                }
                offset += ExBitConverter.Write(num2, buffer, offset);
                offset += num2;
                return;
            }
            if (propId == (StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.Array | StreamPropertyType.List))
            {
                PropertyStreamWriter.WriteList <byte[]>(propId, (List <byte[]>)value, buffer, ref offset);
                return;
            }
            switch (propId)
            {
            case StreamPropertyType.Bool | StreamPropertyType.MultiValuedProperty:
                PropertyStreamWriter.WriteMultiValuedProperty <bool>(propId, (MultiValuedProperty <bool>)value, buffer, ref offset);
                return;

            case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.MultiValuedProperty:
                PropertyStreamWriter.WriteMultiValuedProperty <byte>(propId, (MultiValuedProperty <byte>)value, buffer, ref offset);
                return;

            case StreamPropertyType.SByte | StreamPropertyType.MultiValuedProperty:
                PropertyStreamWriter.WriteMultiValuedProperty <sbyte>(propId, (MultiValuedProperty <sbyte>)value, buffer, ref offset);
                return;

            case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.MultiValuedProperty:
                PropertyStreamWriter.WriteMultiValuedProperty <short>(propId, (MultiValuedProperty <short>)value, buffer, ref offset);
                return;

            case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.MultiValuedProperty:
                PropertyStreamWriter.WriteMultiValuedProperty <ushort>(propId, (MultiValuedProperty <ushort>)value, buffer, ref offset);
                return;

            case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.MultiValuedProperty:
                PropertyStreamWriter.WriteMultiValuedProperty <int>(propId, (MultiValuedProperty <int>)value, buffer, ref offset);
                return;

            case StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty:
                PropertyStreamWriter.WriteMultiValuedProperty <uint>(propId, (MultiValuedProperty <uint>)value, buffer, ref offset);
                return;

            case StreamPropertyType.Null | StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty:
                PropertyStreamWriter.WriteMultiValuedProperty <long>(propId, (MultiValuedProperty <long>)value, buffer, ref offset);
                return;

            case StreamPropertyType.Bool | StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty:
                PropertyStreamWriter.WriteMultiValuedProperty <ulong>(propId, (MultiValuedProperty <ulong>)value, buffer, ref offset);
                return;

            case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty:
                PropertyStreamWriter.WriteMultiValuedProperty <float>(propId, (MultiValuedProperty <float>)value, buffer, ref offset);
                return;

            case StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty:
                PropertyStreamWriter.WriteMultiValuedProperty <double>(propId, (MultiValuedProperty <double>)value, buffer, ref offset);
                return;

            case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty:
                PropertyStreamWriter.WriteMultiValuedProperty <decimal>(propId, (MultiValuedProperty <decimal>)value, buffer, ref offset);
                return;

            case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty:
            {
                char[] value4 = (value != null) ? ((MultiValuedProperty <char>)value).ToArray() : null;
                PropertyStreamWriter.WriteValue(StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.Array, value4, buffer, ref offset);
                return;
            }

            case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty:
                PropertyStreamWriter.WriteMultiValuedProperty <string>(propId, (MultiValuedProperty <string>)value, buffer, ref offset);
                return;

            case StreamPropertyType.DateTime | StreamPropertyType.MultiValuedProperty:
                PropertyStreamWriter.WriteMultiValuedProperty <DateTime>(propId, (MultiValuedProperty <DateTime>)value, buffer, ref offset);
                return;

            case StreamPropertyType.Null | StreamPropertyType.DateTime | StreamPropertyType.MultiValuedProperty:
                PropertyStreamWriter.WriteMultiValuedProperty <Guid>(propId, (MultiValuedProperty <Guid>)value, buffer, ref offset);
                return;

            case StreamPropertyType.Bool | StreamPropertyType.DateTime | StreamPropertyType.MultiValuedProperty:
                PropertyStreamWriter.WriteMultiValuedProperty <IPAddress>(propId, (MultiValuedProperty <IPAddress>)value, buffer, ref offset);
                return;

            case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.DateTime | StreamPropertyType.MultiValuedProperty:
                PropertyStreamWriter.WriteMultiValuedProperty <IPEndPoint>(propId, (MultiValuedProperty <IPEndPoint>)value, buffer, ref offset);
                return;

            case StreamPropertyType.SByte | StreamPropertyType.DateTime | StreamPropertyType.MultiValuedProperty:
            case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.DateTime | StreamPropertyType.MultiValuedProperty:
            case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.DateTime | StreamPropertyType.MultiValuedProperty:
            case StreamPropertyType.UInt32 | StreamPropertyType.DateTime | StreamPropertyType.MultiValuedProperty:
            case StreamPropertyType.Null | StreamPropertyType.UInt32 | StreamPropertyType.DateTime | StreamPropertyType.MultiValuedProperty:
                break;

            case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.DateTime | StreamPropertyType.MultiValuedProperty:
                return;

            default:
                if (propId != (StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.Array | StreamPropertyType.MultiValuedProperty))
                {
                    return;
                }
                PropertyStreamWriter.WriteMultiValuedProperty <byte[]>(propId, (MultiValuedProperty <byte[]>)value, buffer, ref offset);
                return;
            }
IL_808:
            throw new InvalidOperationException(string.Format("Dont know how to handle type {0}", propId));
        }
        internal static int SizeOfValue(StreamPropertyType propType, object value)
        {
            int num = 0;

            if (propType <= (StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.DateTime | StreamPropertyType.List))
            {
                switch (propType)
                {
                case StreamPropertyType.Null:
                    return(num);

                case StreamPropertyType.Bool:
                case StreamPropertyType.Byte:
                case StreamPropertyType.SByte:
                    return(num + 1);

                case StreamPropertyType.Int16:
                case StreamPropertyType.UInt16:
                    return(num + 2);

                case StreamPropertyType.Int32:
                case StreamPropertyType.UInt32:
                case StreamPropertyType.Single:
                case StreamPropertyType.RecipientType:
                    return(num + 4);

                case StreamPropertyType.Int64:
                case StreamPropertyType.UInt64:
                case StreamPropertyType.Double:
                case StreamPropertyType.DateTime:
                    return(num + 8);

                case StreamPropertyType.Decimal:
                case StreamPropertyType.Guid:
                case StreamPropertyType.IPAddress:
                    return(num + 16);

                case StreamPropertyType.Char:
                    return(num + PropertyStreamWriter.SizeOfValue(StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.Array, new char[]
                    {
                        (char)value
                    }));

                case StreamPropertyType.String:
                {
                    num += 4;
                    string text = (string)value;
                    if (!string.IsNullOrEmpty(text))
                    {
                        return(num + Encoding.UTF8.GetByteCount(text));
                    }
                    return(num);
                }

                case StreamPropertyType.IPEndPoint:
                    return(num + 18);

                case StreamPropertyType.RoutingAddress:
                case StreamPropertyType.ADObjectId:
                    goto IL_48F;

                default:
                    switch (propType)
                    {
                    case StreamPropertyType.Bool | StreamPropertyType.Array:
                    case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.Array:
                    case StreamPropertyType.SByte | StreamPropertyType.Array:
                        return(num + (4 + ((Array)value).Length));

                    case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.Array:
                    case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.Array:
                        return(num + (4 + ((Array)value).Length * 2));

                    case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.Array:
                    case StreamPropertyType.UInt32 | StreamPropertyType.Array:
                    case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.UInt32 | StreamPropertyType.Array:
                        return(num + (4 + ((Array)value).Length * 4));

                    case StreamPropertyType.Null | StreamPropertyType.UInt32 | StreamPropertyType.Array:
                    case StreamPropertyType.Bool | StreamPropertyType.UInt32 | StreamPropertyType.Array:
                    case StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.Array:
                    case StreamPropertyType.DateTime | StreamPropertyType.Array:
                        return(num + (4 + ((Array)value).Length * 8));

                    case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.Array:
                    case StreamPropertyType.Null | StreamPropertyType.DateTime | StreamPropertyType.Array:
                    case StreamPropertyType.Bool | StreamPropertyType.DateTime | StreamPropertyType.Array:
                        return(num + (4 + ((Array)value).Length * 16));

                    case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.Array:
                        num += 4;
                        if (value != null)
                        {
                            return(num + Encoding.UTF8.GetByteCount((char[])value));
                        }
                        return(num);

                    case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.Array:
                    {
                        num += 4;
                        string[] array = (string[])value;
                        for (int i = 0; i < array.Length; i++)
                        {
                            num += PropertyStreamWriter.SizeOfValue(StreamPropertyType.String, array[i]);
                        }
                        return(num);
                    }

                    case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.DateTime | StreamPropertyType.Array:
                        return(num + (4 + ((Array)value).Length * 18));

                    default:
                        switch (propType)
                        {
                        case StreamPropertyType.Bool | StreamPropertyType.List:
                        case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.List:
                        case StreamPropertyType.SByte | StreamPropertyType.List:
                            break;

                        case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.List:
                        case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.List:
                            goto IL_308;

                        case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.List:
                        case StreamPropertyType.UInt32 | StreamPropertyType.List:
                        case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.UInt32 | StreamPropertyType.List:
                            goto IL_31F;

                        case StreamPropertyType.Null | StreamPropertyType.UInt32 | StreamPropertyType.List:
                        case StreamPropertyType.Bool | StreamPropertyType.UInt32 | StreamPropertyType.List:
                        case StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.List:
                        case StreamPropertyType.DateTime | StreamPropertyType.List:
                            goto IL_336;

                        case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.List:
                        case StreamPropertyType.Null | StreamPropertyType.DateTime | StreamPropertyType.List:
                        case StreamPropertyType.Bool | StreamPropertyType.DateTime | StreamPropertyType.List:
                            goto IL_34D;

                        case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.List:
                        {
                            List <char> list  = (List <char>)value;
                            char[]      chars = list.ToArray();
                            num += 4;
                            if (value != null)
                            {
                                return(num + Encoding.UTF8.GetByteCount(chars));
                            }
                            return(num);
                        }

                        case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.List:
                            goto IL_3DB;

                        case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.DateTime | StreamPropertyType.List:
                            goto IL_365;

                        default:
                            goto IL_48F;
                        }
                        break;
                    }
                    break;
                }
            }
            else
            {
                if (propType == (StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.Array | StreamPropertyType.List))
                {
                    num += 4;
                    List <byte[]> list2 = (List <byte[]>)value;
                    for (int j = 0; j < list2.Count; j++)
                    {
                        num += PropertyStreamWriter.SizeOfValue(propType & ~StreamPropertyType.List, list2[j]);
                    }
                    return(num);
                }
                switch (propType)
                {
                case StreamPropertyType.Bool | StreamPropertyType.MultiValuedProperty:
                case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.MultiValuedProperty:
                case StreamPropertyType.SByte | StreamPropertyType.MultiValuedProperty:
                    break;

                case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.MultiValuedProperty:
                case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.MultiValuedProperty:
                    goto IL_308;

                case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.MultiValuedProperty:
                case StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty:
                case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty:
                    goto IL_31F;

                case StreamPropertyType.Null | StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty:
                case StreamPropertyType.Bool | StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty:
                case StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty:
                case StreamPropertyType.DateTime | StreamPropertyType.MultiValuedProperty:
                    goto IL_336;

                case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty:
                case StreamPropertyType.Null | StreamPropertyType.DateTime | StreamPropertyType.MultiValuedProperty:
                case StreamPropertyType.Bool | StreamPropertyType.DateTime | StreamPropertyType.MultiValuedProperty:
                    goto IL_34D;

                case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty:
                {
                    MultiValuedProperty <char> multiValuedProperty = (MultiValuedProperty <char>)value;
                    char[] chars2 = multiValuedProperty.ToArray();
                    num += 4;
                    if (value != null)
                    {
                        return(num + Encoding.UTF8.GetByteCount(chars2));
                    }
                    return(num);
                }

                case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty:
                    goto IL_3DB;

                case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.DateTime | StreamPropertyType.MultiValuedProperty:
                    goto IL_365;

                default:
                {
                    if (propType != (StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.Array | StreamPropertyType.MultiValuedProperty))
                    {
                        goto IL_48F;
                    }
                    num += 4;
                    MultiValuedProperty <byte[]> multiValuedProperty2 = (MultiValuedProperty <byte[]>)value;
                    for (int k = 0; k < multiValuedProperty2.Count; k++)
                    {
                        num += PropertyStreamWriter.SizeOfValue(propType & ~StreamPropertyType.MultiValuedProperty, multiValuedProperty2[k]);
                    }
                    return(num);
                }
                }
            }
            return(num + (4 + ((ICollection)value).Count));

IL_308:
            return(num + (4 + ((ICollection)value).Count * 2));

IL_31F:
            return(num + (4 + ((ICollection)value).Count * 4));

IL_336:
            return(num + (4 + ((ICollection)value).Count * 8));

IL_34D:
            return(num + (4 + ((ICollection)value).Count * 16));

IL_365:
            return(num + (4 + ((ICollection)value).Count * 18));

IL_3DB:
            num += 4;
            IList <string> list3 = (IList <string>)value;

            for (int l = 0; l < list3.Count; l++)
            {
                num += PropertyStreamWriter.SizeOfValue(StreamPropertyType.String, list3[l]);
            }
            return(num);

IL_48F:
            throw new InvalidOperationException(string.Format("Data type {0} is unknown", propType));
        }
 public static int SizeOf(StreamPropertyType propType, object value)
 {
     return(2 + PropertyStreamWriter.SizeOfValue(propType, value));
 }
Example #12
0
 public TypedValue(StreamPropertyType type, object value)
 {
     this.Type  = type;
     this.Value = value;
 }