IPersistableObjectTryReplaceProperty Method

Tries to the replace a property value. The replacement will succeed if the currently stored value equals to originalValue. Non-existing value can be represented by MissingProperty so the method supports also "try remove" and "try add" functionality.

Definition

Namespace: KGySoft.ComponentModel
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.0.0
C#
bool TryReplaceProperty(
	string propertyName,
	Object? originalValue,
	Object? newValue,
	bool triggerChangedEvent = true
)

Parameters

propertyName  String
The name of the property.
originalValue  Object
The original value.
newValue  Object
The new value.
triggerChangedEvent  Boolean  (Optional)
to allow raising the PropertyChanged event; otherwise, .

Return Value

Boolean
if the originally stored value equals originalValue and the replacement was successful (even if originalValue equals newValue); otherwise, .

Exceptions

InvalidOperationExceptionCannot get or set the property.

See Also