public static void Main()
if (!int.TryParse(source, out int sourceValue) || !Enum.IsDefined(typeof(source), sourceValue))
Console.WriteLine($"Unable to parse value into a PartySource {source}.");
Console.WriteLine($"success: {(source)sourceValue}");
public static bool TryParse<T>(string value, out T result)
result = (T)Enum.Parse(typeof(T), value, true);
if (typeof(T).GetCustomAttributes(typeof(FlagsAttribute), false).Any())
ok = Enum.IsDefined(typeof(T), result);