This commit is contained in:
CortexCore
2023-10-02 23:24:56 +08:00
parent 8ef5c7ec0a
commit 947e52e748
183 changed files with 107857 additions and 9378 deletions

View File

@@ -7,11 +7,11 @@
}
public interface IOptional<T>
{
bool Allow { get; }
T Value { get; }
bool Allow { get; set; }
T Value { get; set; }
}
[System.Serializable]
public record Optional<T> : IOptional<T>
public class Optional<T> : IOptional<T>
{
#if NET5_0_OR_GREATER
bool allow;
@@ -23,8 +23,18 @@
T value;
#endif
public bool Allow { get => allow; set => allow = value;}
public T Value { get => value; set => this.value = value; }
public void SetValueThenAllow(T newValue) => value = newValue;
public T Value
{
get => value;
set=>this.value=value;
}
public void SetValueThenAllow(T newValue)
{
value = newValue;
allow = true;
}
public void Clear()
{
Allow = false;