This commit is contained in:
CortexCore
2023-11-15 23:54:54 +08:00
parent ee3ecec6cb
commit 3c837a4a33
356 changed files with 73756 additions and 26493 deletions

View File

@@ -1,4 +1,6 @@
namespace BITKit
using System;
namespace BITKit
{
public interface IOptional
{
@@ -9,6 +11,7 @@
{
bool Allow { get; set; }
T Value { get; set; }
T IfNotAllow(T value);
}
[System.Serializable]
public class Optional<T> : IOptional<T>
@@ -29,6 +32,15 @@
set=>this.value=value;
}
public T IfNotAllow(T other)
{
return Allow ? Value : other;
}
public T IfNotAllow(Func<T> other)
{
return Allow ? Value : other.Invoke();
}
public void SetValueThenAllow(T newValue)
{
value = newValue;