public void TransferAmbient(object source, object destination) { if (!(this.PropertyName == Const.EmptyString)) { PropertyInfo property = source.GetType().GetProperty(this.PropertyName); PropertyInfo property2 = destination.GetType().GetProperty(this.PropertyName); if (!(property == (PropertyInfo)null) && !(property2 == (PropertyInfo)null)) { IPropertyDefaults propertyDefaults = source as IPropertyDefaults; if (propertyDefaults != null) { propertyDefaults.DefaultReadBack = true; } try { if (property2.CanWrite) { property2.SetValue(destination, property.GetValue(source, null), null); } } finally { if (propertyDefaults != null) { propertyDefaults.DefaultReadBack = false; } } } } }
public object GetAmbientValue(object value) { if (this.PropertyName == Const.EmptyString) { return(null); } PropertyInfo property = value.GetType().GetProperty(this.PropertyName); if (property == (PropertyInfo)null) { return(null); } IPropertyDefaults propertyDefaults = value as IPropertyDefaults; if (propertyDefaults != null) { propertyDefaults.DefaultReadBack = true; try { return(property.GetValue(value, null)); } finally { propertyDefaults.DefaultReadBack = false; } } return(property.GetValue(value, null)); }