Esempio n. 1
0
        private void WritePropertyCustom(BamlPropertyCustom node)
        {
            BeginVarSize();

            _blob.Write(ref _pos, (short)GetPropertyId(node.DeclaringProperty));

            var value = node.Value;

            short converterId = (short)value.ValueType;

            if (node.IsValueType)
            {
                converterId |= 0x4000;
            }

            _blob.Write(ref _pos, (short)converterId);

            switch (value.ValueType)
            {
            case BamlPropertyValueType.Property:
            {
                var propertyValue = (BamlPropertyValueWithProperty)value;
                if (propertyValue.Property != null)
                {
                    _blob.Write(ref _pos, (short)GetPropertyId(propertyValue.Property));
                }
                else
                {
                    _blob.Write(ref _pos, (short)GetTypeId(propertyValue.Type));
                    _blob.WriteLengthPrefixedString(ref _pos, (string)propertyValue.Name);
                }
            }
            break;

            case BamlPropertyValueType.Boolean:
            {
                var boolValue = (BamlPropertyBoolValue)value;
                _blob.Write(ref _pos, (bool)boolValue.Value);
            }
            break;

            default:
            {
                var customValue = (BamlPropertyCustomValue)value;
                _blob.Write(ref _pos, customValue.Data);
            }
            break;
            }

            WriteVarSize(RecordType.PropertyCustom);
        }
Esempio n. 2
0
        private void ReadPropertyCustom()
        {
            int size = ReadRecordSize();

            var node = new BamlPropertyCustom();

            node.DeclaringProperty = GetProperty(_accessor.ReadInt16());

            short converterId = _accessor.ReadInt16();

            if ((converterId & 0x4000) == 0x4000)
            {
                node.IsValueType = true;
                converterId      = (short)(converterId & ~0x4000);
            }

            node.Value = ReadPropertyValue(converterId, size - 4, node.IsValueType);

            AddNode(node);
        }