Пример #1
0
        // Token: 0x06001FAC RID: 8108 RVA: 0x000953F8 File Offset: 0x000935F8
        internal object GetCustomValue(BinaryReader reader, Type propertyType, short serializerId, BamlRecordReader bamlRecordReader)
        {
            if (serializerId != 46)
            {
                if (serializerId != 195)
                {
                    switch (serializerId)
                    {
                    case 744:
                        this._valueObject = SolidColorBrush.DeserializeFrom(reader, bamlRecordReader.TypeConvertContext);
                        goto IL_11D;

                    case 745:
                        this._valueObject = XamlInt32CollectionSerializer.StaticConvertCustomBinaryToObject(reader);
                        goto IL_11D;

                    case 746:
                        this._valueObject = XamlPathDataSerializer.StaticConvertCustomBinaryToObject(reader);
                        goto IL_11D;

                    case 747:
                        this._valueObject = XamlPoint3DCollectionSerializer.StaticConvertCustomBinaryToObject(reader);
                        goto IL_11D;

                    case 748:
                        this._valueObject = XamlPointCollectionSerializer.StaticConvertCustomBinaryToObject(reader);
                        goto IL_11D;

                    case 752:
                        this._valueObject = XamlVector3DCollectionSerializer.StaticConvertCustomBinaryToObject(reader);
                        goto IL_11D;
                    }
                    return(null);
                }
                uint num;
                if (this._valueObject == null)
                {
                    num = reader.ReadUInt32();
                }
                else
                {
                    num = (uint)this._valueObject;
                }
                if (propertyType.IsEnum)
                {
                    this._valueObject      = Enum.ToObject(propertyType, num);
                    this.ValueObjectSet    = true;
                    this.IsRawEnumValueSet = false;
                }
                else
                {
                    this._valueObject      = num;
                    this.ValueObjectSet    = false;
                    this.IsRawEnumValueSet = true;
                }
                return(this._valueObject);
            }
            else
            {
                byte b = reader.ReadByte();
                this._valueObject = (b == 1);
            }
IL_11D:
            this.ValueObjectSet = true;
            return(this._valueObject);
        }
        // Token: 0x06001F9C RID: 8092 RVA: 0x00094FD0 File Offset: 0x000931D0
        internal override void WriteRecordData(BinaryWriter bamlBinaryWriter)
        {
            int   num = (int)bamlBinaryWriter.Seek(0, SeekOrigin.Current);
            short serializerTypeId = base.SerializerTypeId;

            bamlBinaryWriter.Write(base.AttributeId);
            if (serializerTypeId == 137)
            {
                if (this.ValueMemberName != null)
                {
                    bamlBinaryWriter.Write(serializerTypeId | BamlPropertyCustomRecord.TypeIdValueMask);
                }
                else
                {
                    bamlBinaryWriter.Write(serializerTypeId);
                }
                bamlBinaryWriter.Write(this.ValueId);
                if (this.ValueMemberName != null)
                {
                    bamlBinaryWriter.Write(this.ValueMemberName);
                }
                return;
            }
            bamlBinaryWriter.Write(serializerTypeId);
            bool flag = false;

            if (this.ValueType != null && this.ValueType.IsEnum)
            {
                uint     num2  = 0U;
                string[] array = this.Value.Split(new char[]
                {
                    ','
                });
                foreach (string text in array)
                {
                    FieldInfo field = this.ValueType.GetField(text.Trim(), BindingFlags.IgnoreCase | BindingFlags.Static | BindingFlags.Public);
                    if (!(field != null))
                    {
                        flag = false;
                        break;
                    }
                    object rawConstantValue = field.GetRawConstantValue();
                    num2 += (uint)Convert.ChangeType(rawConstantValue, typeof(uint), TypeConverterHelper.InvariantEnglishUS);
                    flag  = true;
                }
                if (flag)
                {
                    bamlBinaryWriter.Write(num2);
                }
            }
            else if (this.ValueType == typeof(bool))
            {
                TypeConverter converter = TypeDescriptor.GetConverter(typeof(bool));
                object        value     = converter.ConvertFromString(this.TypeContext, TypeConverterHelper.InvariantEnglishUS, this.Value);
                bamlBinaryWriter.Write((byte)Convert.ChangeType(value, typeof(byte), TypeConverterHelper.InvariantEnglishUS));
                flag = true;
            }
            else if (this.SerializerType == typeof(XamlBrushSerializer))
            {
                XamlSerializer xamlSerializer = new XamlBrushSerializer();
                flag = xamlSerializer.ConvertStringToCustomBinary(bamlBinaryWriter, this.Value);
            }
            else if (this.SerializerType == typeof(XamlPoint3DCollectionSerializer))
            {
                XamlSerializer xamlSerializer2 = new XamlPoint3DCollectionSerializer();
                flag = xamlSerializer2.ConvertStringToCustomBinary(bamlBinaryWriter, this.Value);
            }
            else if (this.SerializerType == typeof(XamlVector3DCollectionSerializer))
            {
                XamlSerializer xamlSerializer3 = new XamlVector3DCollectionSerializer();
                flag = xamlSerializer3.ConvertStringToCustomBinary(bamlBinaryWriter, this.Value);
            }
            else if (this.SerializerType == typeof(XamlPointCollectionSerializer))
            {
                XamlSerializer xamlSerializer4 = new XamlPointCollectionSerializer();
                flag = xamlSerializer4.ConvertStringToCustomBinary(bamlBinaryWriter, this.Value);
            }
            else if (this.SerializerType == typeof(XamlInt32CollectionSerializer))
            {
                XamlSerializer xamlSerializer5 = new XamlInt32CollectionSerializer();
                flag = xamlSerializer5.ConvertStringToCustomBinary(bamlBinaryWriter, this.Value);
            }
            else if (this.SerializerType == typeof(XamlPathDataSerializer))
            {
                XamlSerializer xamlSerializer6 = new XamlPathDataSerializer();
                flag = xamlSerializer6.ConvertStringToCustomBinary(bamlBinaryWriter, this.Value);
            }
            if (!flag)
            {
                throw new XamlParseException(SR.Get("ParserBadString", new object[]
                {
                    this.Value,
                    this.ValueType.Name
                }));
            }
        }