ObservableObjectBaseGetT(T, String) Method

Gets the value of a property or defaultValue if no value is stored for it. No new value will be stored if the property does not exist. If the default initial value is too complex and should not be evaluated every time when the property is get, or to throw an exception for an uninitialized property use the other Get overload.
For an example, see the Remarks section of the ObservableObjectBase class.

Definition

Namespace: KGySoft.ComponentModel
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 9.0.0-preview.1
C#
protected T Get<T>(
	T defaultValue = null,
	string propertyName = null
)

Parameters

defaultValue  T  (Optional)
The value to return if property does not exist. This parameter is optional.
Default value: The default value of T type.
propertyName  String  (Optional)
The name of the property to get. This parameter is optional.
Default value: The name of the caller member.

Type Parameters

T
The type of the property.

Return Value

T
The value of the property, or the specified defaultValue.

Exceptions

ArgumentNullExceptionpropertyName is .
InvalidOperationExceptionpropertyName cannot be retrieved.
-or-
CanGetProperty is not overridden and propertyName is not an actual instance property in this instance.
ObjectDisposedExceptionIsDisposed returns whereas AllowReadingDisposedObject returns .

See Also