// Token: 0x06001EC9 RID: 7881 RVA: 0x00093BE4 File Offset: 0x00091DE4 internal BamlRecord CloneRecord(BamlRecord record) { BamlRecordType recordType = record.RecordType; BamlRecord bamlRecord; if (recordType != BamlRecordType.ElementStart) { if (recordType != BamlRecordType.PropertyCustom) { bamlRecord = this.AllocateRecord(record.RecordType); } else if (record is BamlPropertyCustomWriteInfoRecord) { bamlRecord = new BamlPropertyCustomWriteInfoRecord(); } else { bamlRecord = new BamlPropertyCustomRecord(); } } else if (record is BamlNamedElementStartRecord) { bamlRecord = new BamlNamedElementStartRecord(); } else { bamlRecord = new BamlElementStartRecord(); } record.Copy(bamlRecord); return(bamlRecord); }
// Token: 0x06001FAD RID: 8109 RVA: 0x00095530 File Offset: 0x00093730 internal override void Copy(BamlRecord record) { base.Copy(record); BamlPropertyCustomRecord bamlPropertyCustomRecord = (BamlPropertyCustomRecord)record; bamlPropertyCustomRecord._valueObject = this._valueObject; bamlPropertyCustomRecord._attributeId = this._attributeId; bamlPropertyCustomRecord._serializerTypeId = this._serializerTypeId; }
// Read a property record that has value information known only to the // property's ValidType. protected virtual void ReadPropertyCustomRecord(BamlPropertyCustomRecord bamlPropertyRecord) { if (null == CurrentContext || (ReaderFlags.DependencyObject != CurrentContext.ContextType && ReaderFlags.ClrObject != CurrentContext.ContextType)) { ThrowException(SRID.ParserUnexpInBAML, "PropertyCustom"); } // the value of the property object valueObject = null; // Get the element to set the property on object element = GetCurrentObjectData(); // Get the attributeId short attributeId = bamlPropertyRecord.AttributeId; // Identify the property WpfPropertyDefinition propertyDefinition = new WpfPropertyDefinition(this, attributeId, element is DependencyObject); if (!bamlPropertyRecord.ValueObjectSet) { #if !STRESS // Get the value of the property that is obtained from the binary data in the record. try { #endif valueObject = GetCustomValue(bamlPropertyRecord, propertyDefinition.PropertyType, propertyDefinition.Name); #if !STRESS } catch (Exception e) { if( CriticalExceptions.IsCriticalException(e) || e is XamlParseException ) { throw; } string message = SR.Get(SRID.ParserCannotConvertPropertyValue, propertyDefinition.Name, propertyDefinition.PropertyType.FullName); ThrowExceptionWithLine(message, e); } #endif } else { valueObject = bamlPropertyRecord.ValueObject; } FreezeIfRequired(valueObject); if (propertyDefinition.DependencyProperty != null) { Debug.Assert(element is DependencyObject, "Guaranteed by PropertyDefinition constructor"); SetDependencyValue((DependencyObject)element, propertyDefinition.DependencyProperty, valueObject); } else if (propertyDefinition.PropertyInfo != null) { // Regular case for CLR property if (propertyDefinition.IsInternal) { bool set = XamlTypeMapper.SetInternalPropertyValue(ParserContext, ParserContext.RootElement, propertyDefinition.PropertyInfo, element, valueObject); if (!set) { ThrowException(SRID.ParserCantSetAttribute, "property", propertyDefinition.Name, "set"); } } else { propertyDefinition.PropertyInfo.SetValue(element, valueObject, BindingFlags.Default, null, null, TypeConverterHelper.InvariantEnglishUS); } } else if (propertyDefinition.AttachedPropertySetter != null) { propertyDefinition.AttachedPropertySetter.Invoke(null, new object[] { element, valueObject }); } else { ThrowException(SRID.ParserCantGetDPOrPi, GetPropertyNameFromAttributeId(attributeId)); } }
internal object GetCustomValue(BamlPropertyCustomRecord bamlPropertyRecord, Type propertyType, string propertyName) { object valueObject = null; if (!bamlPropertyRecord.ValueObjectSet) { Exception innerException = null; short sid = bamlPropertyRecord.SerializerTypeId; try { if (sid == (short)KnownElements.DependencyPropertyConverter) { valueObject = GetCustomDependencyPropertyValue(bamlPropertyRecord); } else { valueObject = bamlPropertyRecord.GetCustomValue(BinaryReader, propertyType, sid, this); } } catch (Exception e) { if( CriticalExceptions.IsCriticalException(e) || e is XamlParseException ) { throw; } innerException = e; } if (!bamlPropertyRecord.ValueObjectSet && !bamlPropertyRecord.IsRawEnumValueSet) { string message = SR.Get(SRID.ParserCannotConvertPropertyValue, propertyName, propertyType.FullName); ThrowExceptionWithLine(message, innerException); } } else { valueObject = bamlPropertyRecord.ValueObject; } return valueObject; }
internal DependencyProperty GetCustomDependencyPropertyValue(BamlPropertyCustomRecord bamlPropertyRecord, out Type declaringType) { declaringType = null; DependencyProperty dp = null; short serializerTypeId = bamlPropertyRecord.SerializerTypeId; Debug.Assert(serializerTypeId == (short)KnownElements.DependencyPropertyConverter); if (!bamlPropertyRecord.ValueObjectSet) { // Handle DP property value stored as an attribInfo Id. short dpId = BinaryReader.ReadInt16(); string dpName = null; // if ValueId is a TypeId, then get the DP name that is stored next in the record as a string. // else the ValueId is a known DP. if (bamlPropertyRecord.IsValueTypeId) { dpName = BinaryReader.ReadString(); } // Resolve the attribInfo of the prop value read into ValueIdValueId, // into an actual DP instance to be used as the prop value. dp = MapTable.GetDependencyPropertyValueFromId(dpId, dpName, out declaringType); if (dp == null) { ThrowException(SRID.ParserCannotConvertPropertyValue, "Property", typeof(DependencyProperty).FullName); } bamlPropertyRecord.ValueObject = dp; bamlPropertyRecord.ValueObjectSet = true; } else { dp = (DependencyProperty)bamlPropertyRecord.ValueObject; } return dp; }
internal DependencyProperty GetCustomDependencyPropertyValue(BamlPropertyCustomRecord bamlPropertyRecord) { Type declaringType = null; return GetCustomDependencyPropertyValue(bamlPropertyRecord, out declaringType); }