Class BreakableModel
Provides a default implementation for models that can have a broken state
public abstract class BreakableModel : CorePropertyChanged, IBreakableModel
- Inheritance
-
objectCorePropertyChangedBreakableModel
- Implements
- Derived
Properties
BrokenDisplayName
Gets the display name of this breakable model
public abstract string BrokenDisplayName { get; }
Property Value
BrokenState
Gets or sets the broken state of this breakable model, if null this model is not broken.
Note: If setting this manually you are also responsible for invoking BrokenStateChanged
public string? BrokenState { get; set; }
Property Value
BrokenStateException
Gets or sets the exception that caused the broken state
Note: If setting this manually you are also responsible for invoking BrokenStateChanged
public Exception? BrokenStateException { get; set; }
Property Value
Methods
ClearBrokenState(string)
Clears the broken state and exception if BrokenState equals
public void ClearBrokenState(string state)
Parameters
statestring
GetBrokenHierarchy()
Returns a list containing all broken models, including self and any children
public virtual IEnumerable<IBreakableModel> GetBrokenHierarchy()
Returns
OnBrokenStateChanged()
Invokes the BrokenStateChanged event
protected virtual void OnBrokenStateChanged()
SetBrokenState(string, Exception?)
Sets the broken state to the provided state and optional exception.
public void SetBrokenState(string state, Exception? exception = null)
Parameters
statestringThe state to set the broken state to
exceptionExceptionThe exception that caused the broken state
TryOrBreak(Action, string)
Try to execute the provided action. If the action succeeded the broken state is cleared if it matches
public bool TryOrBreak(Action action, string breakMessage)
Parameters
actionActionThe action to attempt to execute
breakMessagestringThe message to clear on succeed or set on failure (exception)
Returns
Events
BrokenStateChanged
Occurs when the broken state of this model changes
public event EventHandler? BrokenStateChanged