mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 12:11:10 +00:00
Implements directory browser dialog, part 1: file system treeview
This commit is contained in:
1 parent
4a53348013
commit
4e4ecbbfca
318 files changed
+6012
-1184
No files matched your search
@@ -4,11 +4,11 @@ namespace Lumina.Domain.Common.Primitives;
|
||||
/// Primitive struct for explicitly handling cases when a value might be unknown or not applicable,
|
||||
/// distinguishing between "not set" and "intentionally empty".
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the value represented by this structure.</typeparam>
|
||||
public readonly struct Optional<T>
|
||||
/// <typeparam name="TValue">The type of the value represented by this structure.</typeparam>
|
||||
public readonly struct Optional<TValue>
|
||||
{
|
||||
#region ================================================================== FIELD MEMBERS ================================================================================
|
||||
private readonly T? _value;
|
||||
private readonly TValue? _value;
|
||||
#endregion
|
||||
|
||||
#region ==================================================================== PROPERTIES =================================================================================
|
||||
@@ -20,7 +20,7 @@ public readonly struct Optional<T>
|
||||
/// <summary>
|
||||
/// Gets the value represented by this structure.
|
||||
/// </summary>
|
||||
public T Value
|
||||
public TValue Value
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -31,11 +31,11 @@ public readonly struct Optional<T>
|
||||
|
||||
#region ====================================================================== CTOR =====================================================================================
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Optional{T}"/> structure.
|
||||
/// Initializes a new instance of the <see cref="Optional{TValue}"/> structure.
|
||||
/// </summary>
|
||||
/// <param name="value">The value represented by this structure.</param>
|
||||
/// <param name="hasValue"><see langword="true"/> if <paramref name="value"/> is not <see langword="null"/>, <see langword="false"/>otherwise.</param>
|
||||
private Optional(T? value, bool hasValue)
|
||||
private Optional(TValue? value, bool hasValue)
|
||||
{
|
||||
_value = value;
|
||||
HasValue = hasValue;
|
||||
@@ -44,50 +44,50 @@ public readonly struct Optional<T>
|
||||
|
||||
#region ===================================================================== METHODS ===================================================================================
|
||||
/// <summary>
|
||||
/// Custom implementation operator for converting <paramref name="value"/> to an <see cref="Optional{T}"/>.
|
||||
/// Custom implementation operator for converting <paramref name="value"/> to an <see cref="Optional{TValue}"/>.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to be converted.</param>
|
||||
public static implicit operator Optional<T>(T value)
|
||||
public static implicit operator Optional<TValue>(TValue value)
|
||||
{
|
||||
return Some(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an <see cref="Optional{T}"/> with a value.
|
||||
/// Creates an <see cref="Optional{TValue}"/> with a value.
|
||||
/// </summary>
|
||||
/// <param name="value">The value to wrap in the <see cref="Optional{T}"/>.</param>
|
||||
/// <returns>An <see cref="Optional{T}"/> containing the specified value.</returns>
|
||||
public static Optional<T> Some(T value)
|
||||
/// <param name="value">The value to wrap in the <see cref="Optional{TValue}"/>.</param>
|
||||
/// <returns>An <see cref="Optional{TValue}"/> containing the specified value.</returns>
|
||||
public static Optional<TValue> Some(TValue value)
|
||||
{
|
||||
return new Optional<T>(value, true);
|
||||
return new Optional<TValue>(value, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an <see cref="Optional{T}"/> with no value.
|
||||
/// Creates an <see cref="Optional{TValue}"/> with no value.
|
||||
/// </summary>
|
||||
/// <returns>An empty <see cref="Optional{T}"/>.</returns>
|
||||
public static Optional<T> None()
|
||||
/// <returns>An empty <see cref="Optional{TValue}"/>.</returns>
|
||||
public static Optional<TValue> None()
|
||||
{
|
||||
return new(default, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an <see cref="Optional{T}"/> from a nullable reference type.
|
||||
/// Creates an <see cref="Optional{TValue}"/> from a nullable reference type.
|
||||
/// </summary>
|
||||
/// <param name="value">The nullable value to convert.</param>
|
||||
/// <returns>An <see cref="Optional{T}"/> representing the nullable value.</returns>
|
||||
public static Optional<T> FromNullable(T? value)
|
||||
/// <returns>An <see cref="Optional{TValue}"/> representing the nullable value.</returns>
|
||||
public static Optional<TValue> FromNullable(TValue? value)
|
||||
{
|
||||
return value is null ? None() : Some(value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates an <see cref="Optional{T}"/> from a nullable value type.
|
||||
/// Creates an <see cref="Optional{TValue}"/> from a nullable value type.
|
||||
/// </summary>
|
||||
/// <typeparam name="TValue">The underlying value type.</typeparam>
|
||||
/// <typeparam name="TNullableValue">The underlying value type.</typeparam>
|
||||
/// <param name="value">The nullable value to convert.</param>
|
||||
/// <returns>An <see cref="Optional{T}"/> representing the nullable value.</returns>
|
||||
public static Optional<T> FromNullable<TValue>(TValue? value) where TValue : struct, T
|
||||
/// <returns>An <see cref="Optional{TValue}"/> representing the nullable value.</returns>
|
||||
public static Optional<TValue> FromNullable<TNullableValue>(TNullableValue? value) where TNullableValue : struct, TValue
|
||||
{
|
||||
return value.HasValue ? Some(value.Value) : None();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user