PersistableObjectBase Class

Provides a base class for component model classes, which provide a public access to their internal property storage located in the ObservableObjectBase base class by implementing also the IPersistableObject interface.
For details see the Remarks section.

Definition

Namespace: KGySoft.ComponentModel
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 9.0.0-preview.1
C#
[SerializableAttribute]
public abstract class PersistableObjectBase : ObservableObjectBase, 
	IPersistableObject, INotifyPropertyChanged
Inheritance
Object    ObservableObjectBase    PersistableObjectBase
Derived
Implements
IPersistableObject, INotifyPropertyChanged

Remarks

The class should be cast to IPersistableObject to access the property storage and allow to manipulate the properties by name. All of the actually stored values can be read and restored by the GetProperties and SetProperties methods.

The IPersistableObject also provides some concurrent-proof operations if the instance is accessed from multiple threads. See the TryGetPropertyValue, GetPropertyOrDefault and TryReplaceProperty methods.

  Notes to Implementers

For an example see the Remarks section of the ObservableObjectBase class. The same applies also for the PersistableObjectBase class in terms of implementation.

Constructors

PersistableObjectBaseInitializes a new instance of the PersistableObjectBase class

Properties

AllowReadingDisposedObject Gets whether the Get<T> method (and the observable properties using it) throw an ObjectDisposedException when the IsDisposed property returns . In a derived class this property can be overridden to return , in which case the Get<T> method returns the default value of T after the object is disposed.
The base implementation returns .
(Inherited from ObservableObjectBase)
IsDisposed Gets whether this instance has already been disposed.
(Inherited from ObservableObjectBase)
IsModified Gets whether this instance has been modified. Modified state can be set by the SetModified method.
(Inherited from ObservableObjectBase)

Methods

AffectsModifiedState Gets whether the change of the specified propertyName affects the IsModified property.
The ObservableObjectBase implementation excludes the IsModified property itself.
(Inherited from ObservableObjectBase)
CanGetProperty Gets whether the specified property can be retrieved.
The base implementation allows to get the actual instance properties in this instance.
(Inherited from ObservableObjectBase)
CanSetProperty Gets whether the specified property can be set.
The base implementation allows to set the actual instance properties in this instance if the specified value is compatible with the property type.
(Inherited from ObservableObjectBase)
Clone Creates a new object that is a copy of the current instance.
The base implementation clones the internal property storage, the IsModified property and if clonePropertyChanged is , then also the subscribers of the PropertyChanged event. It respects the implementations with some special handling for arrays so arrays can be deep-cloned as well.
(Inherited from ObservableObjectBase)
Dispose Releases the resources held by this instance.
(Inherited from ObservableObjectBase)
Dispose(Boolean) Releases the resources held by this instance.
The base implementation removes the subscribers of the PropertyChanged event and clears the property storage. If the overridden method disposes properties accessed by the Get<T> and Set methods, then check the IsDisposed property first and call the base method as the last step to prevent ObjectDisposedException.
(Inherited from ObservableObjectBase)
GetT(FuncT, String) Gets the value of a property, or - if it was not set before -, then creates its initial value. The created initial value will be stored in the internal property storage without triggering the PropertyChanged event. For constant or simple expressions, or to return a default value for a non-existing property without storing it internally use the other Get overload.
For an example, see the Remarks section of the ObservableObjectBase class.
(Inherited from ObservableObjectBase)
GetT(T, String) 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.
(Inherited from ObservableObjectBase)
OnPropertyChanged Raises the PropertyChanged event.
(Inherited from ObservableObjectBase)
ResetProperty Resets the property of the specified name, meaning, it will be removed from the underlying storage so the getter methods will return the default value again.
(Inherited from ObservableObjectBase)
ResumeChangedEvent Resumes the raising of the PropertyChanged event suspended by the SuspendChangeEvents method.
(Inherited from ObservableObjectBase)
Set Sets the value of a property.
For an example, see the Remarks section of the ObservableObjectBase class.
(Inherited from ObservableObjectBase)
SetModified Sets the modified state of this ObservableObjectBase instance represented by the IsModified property.
(Inherited from ObservableObjectBase)
SuspendChangedEvent Suspends the raising of the PropertyChanged event until ResumeChangeEvents method is called. Supports nested calls.
(Inherited from ObservableObjectBase)

Events

PropertyChanged Occurs when a property value changed. The actual type of the event argument is PropertyChangedExtendedEventArgs.
(Inherited from ObservableObjectBase)

Extension Methods

Convert Converts an Object specified in the obj parameter to the desired targetType.
See the Examples section of the generic ConvertTTarget(Object, CultureInfo) overload for an example.
(Defined by ObjectExtensions)
ConvertTTarget Converts an Object specified in the obj parameter to the desired TTarget.
(Defined by ObjectExtensions)
CreatePropertyBinding Creates a special binding for the PropertyChanged event of the specified source, which allows to update the specified targetPropertyName in the targets, when the property of sourcePropertyName changes in the source.
(Defined by Command)
CreatePropertyBinding Creates a special binding for the PropertyChanged event of the specified source, which allows to update the specified targetPropertyName in the targets, when the property of sourcePropertyName changes in the source.
(Defined by Command)
CreatePropertyChangedHandlerBinding Creates a special command binding for the PropertyChanged event of the specified source that invokes the specified handler only when the changed property is among the specified propertyNames.
(Defined by Command)
CreatePropertyChangedHandlerBinding Creates a special command binding for the PropertyChanged event of the specified source that invokes the specified handler only when the changed property is among the specified propertyNames.
(Defined by Command)
CreateSynchronizedPropertyBinding Creates a special binding for the PropertyChanged event of the specified source, which allows to update the specified targetPropertyName in the targets, when the property of sourcePropertyName changes in the source. The target properties will be set using the SynchronizationContext of the thread on which this method was called.
(Defined by Command)
CreateSynchronizedPropertyBinding Creates a special binding for the PropertyChanged event of the specified source, which allows to update the specified targetPropertyName in the targets, when the property of sourcePropertyName changes in the source. The target properties will be set using the SynchronizationContext of the thread on which this method was called.
(Defined by Command)
CreateTwoWayPropertyBinding Creates a pair of special bindings for the PropertyChanged event of the specified source and target, which allow to update the specified targetPropertyName and sourcePropertyName in both directions when any of them changes.
(Defined by Command)
In Gets whether item is among the elements of set.
See the Examples section of the generic InT(T, T) overload for an example.
(Defined by ObjectExtensions)
TryConvert Tries to convert an Object specified in the obj parameter to the desired targetType.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)
TryConvert Tries to convert an Object specified in the obj parameter to the desired targetType.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)
TryConvertTTarget Tries to convert an Object specified in the obj parameter to the desired TTarget.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)
TryConvertTTarget Tries to convert an Object specified in the obj parameter to the desired TTarget.
See the Examples section of the ConvertTTarget(Object, CultureInfo) method for a related example.
(Defined by ObjectExtensions)

Thread Safety

Static members of this type are safe for multi-threaded operations. Instance members of this type are safe for multi-threaded operations.

See Also