A base class for Cascade models that handles property change notifications, property mutations, and proxy functionality.
More...
|
| | SuperModel (SuperModel? proxyFor=null) |
| | Initializes a new instance of the SuperModel with an optional proxy model.
|
| void | __SetProxyFor (SuperModel? value, bool keepChanges, bool raiseIncoming) |
| | Sets a new proxy model and optionally retains changes or raises property change events.
|
| IDictionary< string, object?> | __GetChanges () |
| | When acting as a proxy to another object, this method returns changes that have been made on this object vs the proxied object.
|
| void | __ApplyChanges (IDictionary< string, object?> changes) |
| | Applies a set of changes to the properties of the model.
|
|
void | __ClearChanges () |
| | Clears all changes made to the model, resetting the property state to the proxy model values.
|
| void | __mutateWith (Action< SuperModel > action) |
| | Executes an action that mutates the model, restoring the original mutation state afterwards.
|
| void | RaisePropertyChanged ([CallerMemberName] string propertyName=null) |
| | Raises a property changed notification for the specified property name.
|
| SuperModel | Clone (IDictionary< string, object?>? changes=null) |
| | Creates a shallow copy of the current SuperModel, optionally applying additional property changes.
|
|
| bool | SetProperty< T > (ref T backingStore, T value, [CallerMemberName] string propertyName="", Action onChanged=null) |
| | Sets a property value and raises property change notifications if the value has changed.
|
| T | GetProperty< T > (ref T backingStore, [CallerMemberName] string propertyName="", Action onChanged=null) |
| | Gets a property value, taking into account whether it's overridden by a proxy.
|
| virtual void | OnPropertyChanged (PropertyChangedEventArgs args) |
| | Raises the PropertyChanged event with the provided arguments.
|
| void | OnProxyForOnPropertyChanged (object sender, PropertyChangedEventArgs e) |
| | Handles property change events from the proxy model and re-raises them for this model.
|
|
|
SuperModel? | _proxyFor |
|
readonly ConcurrentDictionary< string, bool > | _propertySet = new ConcurrentDictionary<string, bool>() |
|
|
bool | __mutable [get, set] |
| | Gets or sets the mutable state of the model. When false, attempting to modify properties will throw a MutationAttemptException.
|
|
SuperModel? | __ProxyFor [get] |
| | The proxy model that this model is currently proxying for, if any.
|
|
bool | __HasChanges [get] |
| | True if there are any uncommitted property changes in this model.
|
|
|
PropertyChangedEventHandler? | PropertyChanged |
A base class for Cascade models that handles property change notifications, property mutations, and proxy functionality.
◆ SuperModel()
| Buzzware.Cascade.SuperModel.SuperModel |
( |
SuperModel? | proxyFor = null | ) |
|
|
inline |
Initializes a new instance of the SuperModel with an optional proxy model.
- Parameters
-
| proxyFor | (optional) a SuperModel that this new instance will act as a proxy for. |
◆ __ApplyChanges()
| void Buzzware.Cascade.SuperModel.__ApplyChanges |
( |
IDictionary< string, object?> | changes | ) |
|
|
inline |
Applies a set of changes to the properties of the model.
- Parameters
-
| changes | A dictionary containing property names and the values to apply. |
◆ __GetChanges()
| IDictionary< string, object?> Buzzware.Cascade.SuperModel.__GetChanges |
( |
| ) |
|
|
inline |
When acting as a proxy to another object, this method returns changes that have been made on this object vs the proxied object.
- Returns
- A dictionary of property names and their values.
◆ __mutateWith()
| void Buzzware.Cascade.SuperModel.__mutateWith |
( |
Action< SuperModel > | action | ) |
|
|
inline |
Executes an action that mutates the model, restoring the original mutation state afterwards.
- Parameters
-
| action | The action to perform which mutates the model. |
◆ __SetProxyFor()
| void Buzzware.Cascade.SuperModel.__SetProxyFor |
( |
SuperModel? | value, |
|
|
bool | keepChanges, |
|
|
bool | raiseIncoming ) |
|
inline |
Sets a new proxy model and optionally retains changes or raises property change events.
- Parameters
-
| value | The new proxy model to set. |
| keepChanges | maintain property changes while changing proxied instance |
| raiseIncoming | raise PropertyChanged events for differing values in new proxy instance |
◆ Clone()
| SuperModel Buzzware.Cascade.SuperModel.Clone |
( |
IDictionary< string, object?>? | changes = null | ) |
|
|
inline |
Creates a shallow copy of the current SuperModel, optionally applying additional property changes.
- Parameters
-
| changes | Optional dictionary of changes to apply to the cloned instance. |
- Returns
- A new SuperModel instance that is a clone of the current instance with applied changes.
◆ GetProperty< T >()
| T Buzzware.Cascade.SuperModel.GetProperty< T > |
( |
ref T | backingStore, |
|
|
[CallerMemberName] string | propertyName = "", |
|
|
Action | onChanged = null ) |
|
inlineprotected |
Gets a property value, taking into account whether it's overridden by a proxy.
- Template Parameters
-
| T | The type of the property. |
- Parameters
-
| backingStore | The reference to the private backing field of the property. |
| propertyName | The name of the property, automatically filled in by the compiler. |
| onChanged | An optional action to perform when the property value is accessed. |
- Returns
- The current value of the property.
◆ OnPropertyChanged()
| virtual void Buzzware.Cascade.SuperModel.OnPropertyChanged |
( |
PropertyChangedEventArgs | args | ) |
|
|
inlineprotectedvirtual |
Raises the PropertyChanged event with the provided arguments.
- Parameters
-
| args | The property changed event arguments. |
◆ OnProxyForOnPropertyChanged()
| void Buzzware.Cascade.SuperModel.OnProxyForOnPropertyChanged |
( |
object | sender, |
|
|
PropertyChangedEventArgs | e ) |
|
inlineprotected |
Handles property change events from the proxy model and re-raises them for this model.
- Parameters
-
| sender | The sender of the property changed event. |
| e | The property changed event arguments. |
◆ RaisePropertyChanged()
| void Buzzware.Cascade.SuperModel.RaisePropertyChanged |
( |
[CallerMemberName] string | propertyName = null | ) |
|
|
inline |
Raises a property changed notification for the specified property name.
- Parameters
-
| propertyName | The name of the property. |
◆ SetProperty< T >()
| bool Buzzware.Cascade.SuperModel.SetProperty< T > |
( |
ref T | backingStore, |
|
|
T | value, |
|
|
[CallerMemberName] string | propertyName = "", |
|
|
Action | onChanged = null ) |
|
inlineprotected |
Sets a property value and raises property change notifications if the value has changed.
- Template Parameters
-
| T | The type of the property. |
- Parameters
-
| backingStore | The reference to the private backing field of the property. |
| value | The new value to set. |
| propertyName | The name of the property, automatically filled in by the compiler. |
| onChanged | An optional action to perform when the property value changes. |
- Returns
- True if the value has changed, otherwise false.
- Exceptions
-
| MutationAttemptException | Thrown if a mutation is attempted when __mutable is false. |
The documentation for this class was generated from the following file:
- Buzzware.Cascade/SuperModel.cs