mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Create and use more passthrough methods
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user