using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using Artemis.Core.Modules;
using ReactiveUI;
namespace Artemis.UI.Shared.DataModelVisualization;
///
/// Represents a input view model
///
/// The type of the data model
public abstract class DataModelInputViewModel : DataModelInputViewModel
{
private bool _closed;
[AllowNull] private T _inputValue;
///
/// Creates a new instance of the class
///
/// The description of the property this input VM is representing
/// The initial value to set the input value to
protected DataModelInputViewModel(DataModelPropertyAttribute targetDescription, T initialValue)
{
TargetDescription = targetDescription;
InputValue = initialValue;
}
///
/// Gets or sets the value shown in the input
///
[AllowNull]
public T InputValue
{
get => _inputValue;
set => this.RaiseAndSetIfChanged(ref _inputValue, value);
}
///
/// Gets the description of the property this input VM is representing
///
public DataModelPropertyAttribute TargetDescription { get; }
internal override object InternalGuard { get; } = new();
///
public sealed override void Submit()
{
if (_closed)
return;
_closed = true;
OnSubmit();
UpdateCallback(InputValue, true);
}
///
public sealed override void Cancel()
{
if (_closed)
return;
_closed = true;
OnCancel();
UpdateCallback(InputValue, false);
}
}
///
/// For internal use only, implement instead.
///
public abstract class DataModelInputViewModel : ReactiveObject
{
///
/// Prevents this type being implemented directly, implement instead.
///
// ReSharper disable once UnusedMember.Global
internal abstract object InternalGuard { get; }
internal Action