using Artemis.Core.DataModelExpansions; using Stylet; namespace Artemis.UI.Shared { /// /// Represents a display view model /// /// The type of the data model public abstract class DataModelDisplayViewModel : DataModelDisplayViewModel { private T _displayValue; /// /// Gets or sets value that the view model must display /// public T DisplayValue { get => _displayValue; set { if (!SetAndNotify(ref _displayValue, value)) return; OnDisplayValueUpdated(); } } internal override object InternalGuard => null; /// public override void UpdateValue(object model) { DisplayValue = model is T value ? value : default; } /// /// Occurs when the display value is updated /// protected virtual void OnDisplayValueUpdated() { } } /// /// For internal use only, implement instead. /// public abstract class DataModelDisplayViewModel : PropertyChangedBase { private DataModelPropertyAttribute _propertyDescription; /// /// Gets the property description of this value /// public DataModelPropertyAttribute PropertyDescription { get => _propertyDescription; internal set => SetAndNotify(ref _propertyDescription, value); } /// /// Prevents this type being implemented directly, implement instead. /// internal abstract object InternalGuard { get; } /// /// Updates the display value /// /// The value to set public abstract void UpdateValue(object model); } }