InputHandler, CreateContainer user command
This commit is contained in:
@@ -13,6 +13,10 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DynamicData" Version="7.7.14" />
|
||||
<PackageReference Include="PropertyChanged.SourceGenerator" Version="1.0.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="System.Reactive" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace FileTime.Core.Interactions;
|
||||
|
||||
public interface IInputElement
|
||||
{
|
||||
InputType Type { get; }
|
||||
string Label { get; }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace FileTime.Core.Interactions;
|
||||
|
||||
public interface IInputInterface
|
||||
{
|
||||
Task<bool> ReadInputs(IEnumerable<IInputElement> fields);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace FileTime.Core.Interactions;
|
||||
|
||||
public interface IOptionElement
|
||||
{
|
||||
string Text { get; }
|
||||
object? Value { get; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace FileTime.Core.Interactions;
|
||||
|
||||
public interface IOptionsInputElement : IInputElement
|
||||
{
|
||||
object Value { get; set; }
|
||||
IEnumerable<IOptionElement> Options { get; }
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace FileTime.Core.Interactions;
|
||||
|
||||
public abstract class InputElementBase : IInputElement
|
||||
{
|
||||
public InputType Type { get; }
|
||||
public string Label { get; }
|
||||
|
||||
protected InputElementBase(string label, InputType type)
|
||||
{
|
||||
Label = label;
|
||||
Type = type;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace FileTime.Core.Interactions;
|
||||
|
||||
public enum InputType
|
||||
{
|
||||
Options,
|
||||
Password,
|
||||
Text,
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace FileTime.Core.Interactions;
|
||||
|
||||
public class OptionElement<T> : IOptionElement
|
||||
{
|
||||
public string Text { get; }
|
||||
public T Value { get; }
|
||||
|
||||
object IOptionElement.Value => Value;
|
||||
|
||||
public OptionElement(string text, T value)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(value);
|
||||
|
||||
Text = text;
|
||||
Value = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System.ComponentModel;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
|
||||
namespace FileTime.Core.Interactions;
|
||||
|
||||
public partial class OptionsInputElement<T> : InputElementBase, IOptionsInputElement, INotifyPropertyChanged
|
||||
{
|
||||
public IEnumerable<OptionElement<T>> Options { get; }
|
||||
|
||||
[Notify] private T? _value;
|
||||
|
||||
IEnumerable<IOptionElement> IOptionsInputElement.Options => Options;
|
||||
object? IOptionsInputElement.Value
|
||||
{
|
||||
get => Value;
|
||||
set => Value = (T?)value;
|
||||
}
|
||||
|
||||
public OptionsInputElement(string label, IEnumerable<OptionElement<T>> options) : base(label, InputType.Options)
|
||||
{
|
||||
Options = options;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System.ComponentModel;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
|
||||
namespace FileTime.Core.Interactions;
|
||||
|
||||
public partial class PasswordInputElement : InputElementBase, INotifyPropertyChanged
|
||||
{
|
||||
public char PasswordChar { get; }
|
||||
|
||||
[Notify] private string? _value;
|
||||
|
||||
public PasswordInputElement(string label, string? value = null, char passwordChar = '*') : base(label, InputType.Password)
|
||||
{
|
||||
PasswordChar = passwordChar;
|
||||
_value = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.ComponentModel;
|
||||
using PropertyChanged.SourceGenerator;
|
||||
|
||||
namespace FileTime.Core.Interactions;
|
||||
|
||||
public partial class TextInputElement : InputElementBase, INotifyPropertyChanged
|
||||
{
|
||||
[Notify] private string? _value;
|
||||
|
||||
public TextInputElement(string label, string? value = null) : base(label, InputType.Text)
|
||||
{
|
||||
_value = value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user