DataContractBase.SetProperty<T> Method (T, T, String, Boolean)
Changes the property to the given value. Returns whether the new value is different from the old value.
Assembly: Microsoft.MasterDataServices.Services.Contracts (in Microsoft.MasterDataServices.Services.Contracts.dll)
protected bool SetProperty<T>( ref T propertyBackingField, T newValue, string propertyName = null, bool emptyStringIsNull = false )
The backing field of the property to change.
The new value to give to the property.
The name of the property. It is recommended that this value be hardcoded by the method caller, rather than using a less performant (but more refactor-friendly) approach like using reflection or lambda expressions to get the property name. The downside of hardcoding is vulnerability to typo and copy-paste type errors. However, this vulnerability is mitigated by unit tests that use reflection to verify this parameter for all data contract class properties. The idea being that it is better to pay the reflection performance penalty in the unit tests, rather than in production code.
A flag that indicates what to do if newValue happens to be an empty string. If this value is set to true, empty strings are treated the same as null values. That is to say that if the existing value is null and an empty string is set with this flag on, it will have no effect.
Return ValueType: System.Boolean
Whether the property was changed. I.e, whether the given new value is different from the property's old value.
The property type.