using System;
using System.Collections.Generic;
namespace Artemis.Core
{
///
/// Represents a model that can have a broken state
///
public interface IBreakableModel
{
///
/// Gets the display name of this breakable model
///
string BrokenDisplayName { get; }
///
/// Gets or sets the broken state of this breakable model, if this model is not broken.
///
string? BrokenState { get; set; }
///
/// Gets or sets the exception that caused the broken state
///
Exception? BrokenStateException { get; set; }
///
/// Try to execute the provided action. If the action succeeded the broken state is cleared if it matches
/// , if the action throws an exception and
/// are set accordingly.
///
/// The action to attempt to execute
/// The message to clear on succeed or set on failure (exception)
/// if the action succeeded; otherwise .
bool TryOrBreak(Action action, string breakMessage);
///
/// Sets the broken state to the provided state and optional exception.
///
/// The state to set the broken state to
/// The exception that caused the broken state
public void SetBrokenState(string state, Exception? exception);
///
/// Clears the broken state and exception if equals .
///
///
public void ClearBrokenState(string state);
///
/// Returns a list containing all broken models, including self and any children
///
IEnumerable GetBrokenHierarchy();
///
/// Occurs when the broken state of this model changes
///
event EventHandler BrokenStateChanged;
}
}