Add flag for value being set

This commit is contained in:
Matt Nadareski
2024-12-04 20:30:21 -05:00
parent 6feda0e69d
commit ab88f8ffaa
3 changed files with 23 additions and 14 deletions

View File

@@ -26,6 +26,7 @@
- Add BaseExecutionContext tests
- Add currently unused Input type
- Split Input type into typed classes
- Add flag for value being set
### 3.2.4 (2024-11-24)

View File

@@ -14,6 +14,11 @@ namespace MPF.ExecutionContexts.Data
/// </summary>
public readonly string Name;
/// <summary>
/// Indicates if a value has been set
/// </summary>
public abstract bool ValueSet { get; }
/// <summary>
/// Verbose name for the input
/// </summary>
@@ -66,6 +71,18 @@ namespace MPF.ExecutionContexts.Data
#endregion
#region Processors
/// <summary>
/// Process the current index, if possible
/// </summary>
/// <param name="parts">Parts array to be referenced</param>
/// <param name="index">Reference to the position in the parts</param>
/// <returns>True if a value could be determined, false otherwise</returns>
public abstract bool Process(string[] parts, ref int index);
#endregion
#region Helpers
/// <summary>
@@ -171,6 +188,9 @@ namespace MPF.ExecutionContexts.Data
/// </summary>
public T? Value { get; protected set; }
/// <inheritdoc/>
public override bool ValueSet => Value != null;
#endregion
#region Constructors
@@ -192,17 +212,5 @@ namespace MPF.ExecutionContexts.Data
: base(shortName, longName, required) { }
#endregion
#region Processors
/// <summary>
/// Process the current index, if possible
/// </summary>
/// <param name="parts">Parts array to be referenced</param>
/// <param name="index">Reference to the position in the parts</param>
/// <returns>True if a value could be determined, false otherwise</returns>
public abstract bool Process(string[] parts, ref int index);
#endregion
}
}

View File

@@ -62,7 +62,7 @@ namespace MPF.ExecutionContexts.Data
if (ulong.TryParse(baseVal, out value))
{
index++;
Value = (ulong)(value * factor);
Value = (ulong)(value * (ulong)factor);
return true;
}
@@ -71,7 +71,7 @@ namespace MPF.ExecutionContexts.Data
if (ulong.TryParse(hexValue, NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture, out value))
{
index++;
Value = (ulong)(value * factor);
Value = (ulong)(value * (ulong)factor);
return true;
}