Files
MPF/MPF.Frontend/StringEventArgs.cs

52 lines
1.6 KiB
C#
Raw Normal View History

2024-05-22 14:29:37 -04:00
using System;
using System.Text;
2024-05-28 13:47:06 -04:00
namespace MPF.Frontend
2024-05-22 14:14:18 -04:00
{
/// <summary>
/// String wrapper for event arguments
/// </summary>
2024-05-22 14:29:37 -04:00
public class StringEventArgs : EventArgs
2024-05-22 14:14:18 -04:00
{
2024-05-22 14:29:37 -04:00
/// <summary>
/// String represented by the event arguments
/// </summary>
private readonly string _value;
/// <summary>
/// Constructor for string values
/// </summary>
public StringEventArgs(string? value)
{
_value = value ?? string.Empty;
}
/// <summary>
/// Constructor for StringBuilder values
/// </summary>
public StringEventArgs(StringBuilder? value)
{
_value = value?.ToString() ?? string.Empty;
}
2024-05-22 14:24:16 -04:00
/// <summary>
/// Event arguments are just the value of the string contained within
2024-05-22 14:24:16 -04:00
/// </summary>
2024-05-22 14:29:37 -04:00
public static implicit operator string(StringEventArgs args) => args._value;
/// <summary>
/// Event arguments are just the value of the string contained within
/// </summary>
public static implicit operator StringBuilder(StringEventArgs args) => new(args._value);
/// <summary>
/// Event arguments are just the value of the string contained within
/// </summary>
public static implicit operator StringEventArgs(string? str) => new(str);
/// <summary>
/// Event arguments are just the value of the string contained within
/// </summary>
public static implicit operator StringEventArgs(StringBuilder? sb) => new(sb);
2024-05-22 14:14:18 -04:00
}
}