private void InitializeConverters() { //call this to let special converters like the one for XmlPropertySetting to get the actual converter from //the actaul serialized RadPoperty this.objectType = this.converter.GetActualPropertyType(this.propertyOwner, this.Property); //since "Property" attribute carries information how "Value" attribute should be processed, //this fix ensures that order of attributes does not brake the parser if (objectType == null) { if (!shouldWaitForAttribute) { shouldWaitForAttribute = true; return; } else //wait only once { throw new InvalidOperationException("Attribute PropertyName of a PropertySetting not found during deserialization."); } } //test if there is RadProperty this.radProperty = this.converter.GetRadProperty(this.propertyOwner, this.Property); TypeConverter newTypeConverter = null; if (this.radProperty != null) { PropertyDescriptor clrProperty = this.radProperty.FindClrProperty(); if (clrProperty != null) { newTypeConverter = clrProperty.Converter; } } if (newTypeConverter == null) { newTypeConverter = TypeDescriptor.GetConverter(objectType); } if (newTypeConverter.CanConvertFrom(typeof(string)) && newTypeConverter.CanConvertTo(typeof(string))) { this.isSerializedAsString = true; this.typeConverter = newTypeConverter; //mark to use typeConverter instaed of given converter this.converter = null; } else { this.isSerializedAsString = false; } }
public ObjectSerializationInfo(ComponentXmlSerializer serializer, SerializationConverter converter, object propertyOwner, PropertyDescriptor property) : this(serializer) { this.converter = converter; this.propertyOwner = propertyOwner; this.property = property; if (converter != null) { InitializeConverters(); } else { this.isSerializedAsString = false; } }
private void InitializeConverters() { this.objectType = this.converter.GetActualPropertyType(this.propertyOwner, this.Property); if ((object)this.objectType == null) { if (this.shouldWaitForAttribute) { throw new InvalidOperationException("Attribute PropertyName of a PropertySetting not found during deserialization."); } this.shouldWaitForAttribute = true; } else { this.radProperty = this.converter.GetRadProperty(this.propertyOwner, this.Property); TypeConverter typeConverter = (TypeConverter)null; if (this.radProperty != null) { PropertyDescriptor clrProperty = this.radProperty.FindClrProperty(); if (clrProperty != null) { typeConverter = clrProperty.Converter; } } if (typeConverter == null) { typeConverter = TypeDescriptor.GetConverter(this.objectType); } if (typeConverter.CanConvertFrom(typeof(string)) && typeConverter.CanConvertTo(typeof(string))) { this.isSerializedAsString = true; this.typeConverter = typeConverter; this.converter = (SerializationConverter)null; } else { this.isSerializedAsString = false; } } }