Create and use more passthrough methods

This commit is contained in:
Matt Nadareski
2024-03-11 15:46:44 -04:00
parent c7b1ce5233
commit eb9075e47e
54 changed files with 1473 additions and 1247 deletions

View File

@@ -130,6 +130,81 @@ namespace SabreTools.DatItems
return _machine.Read<T>(fieldName!);
}
/// <summary>
/// Get the value from a field based on the type provided
/// </summary>
/// <param name="fieldName">Field to retrieve</param>
/// <returns>Value from the field, if possible</returns>
public bool? GetBoolFieldValue(string? fieldName)
{
// Invalid field cannot be processed
if (string.IsNullOrEmpty(fieldName) || !_machine.ContainsKey(fieldName!))
return default;
// Get the value based on the type
return _machine.ReadBool(fieldName!);
}
/// <summary>
/// Get the value from a field based on the type provided
/// </summary>
/// <param name="fieldName">Field to retrieve</param>
/// <returns>Value from the field, if possible</returns>
public double? GetDoubleFieldValue(string? fieldName)
{
// Invalid field cannot be processed
if (string.IsNullOrEmpty(fieldName) || !_machine.ContainsKey(fieldName!))
return default;
// Get the value based on the type
return _machine.ReadDouble(fieldName!);
}
/// <summary>
/// Get the value from a field based on the type provided
/// </summary>
/// <param name="fieldName">Field to retrieve</param>
/// <returns>Value from the field, if possible</returns>
public long? GetInt64FieldValue(string? fieldName)
{
// Invalid field cannot be processed
if (string.IsNullOrEmpty(fieldName) || !_machine.ContainsKey(fieldName!))
return default;
// Get the value based on the type
return _machine.ReadLong(fieldName!);
}
/// <summary>
/// Get the value from a field based on the type provided
/// </summary>
/// <param name="fieldName">Field to retrieve</param>
/// <returns>Value from the field, if possible</returns>
public string? GetStringFieldValue(string? fieldName)
{
// Invalid field cannot be processed
if (string.IsNullOrEmpty(fieldName) || !_machine.ContainsKey(fieldName!))
return default;
// Get the value based on the type
return _machine.ReadString(fieldName!);
}
/// <summary>
/// Get the value from a field based on the type provided
/// </summary>
/// <param name="fieldName">Field to retrieve</param>
/// <returns>Value from the field, if possible</returns>
public string[]? GetStringArrayFieldValue(string? fieldName)
{
// Invalid field cannot be processed
if (string.IsNullOrEmpty(fieldName) || !_machine.ContainsKey(fieldName!))
return default;
// Get the value based on the type
return _machine.ReadStringArray(fieldName!);
}
/// <summary>
/// Set the value from a field based on the type provided
/// </summary>