Skip to content

Commit

Permalink
Update QuestAreaCodeType.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
lastbattle committed Oct 21, 2024
1 parent 7270b9e commit d1ece85
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static string ToReadableString(this QuestAreaCodeType state)
}

/// <summary>
/// Converts from the string back to enum
/// Converts from the string name back to enum
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
Expand All @@ -69,6 +69,24 @@ public static QuestAreaCodeType ToEnum(this string name)
}
return QuestAreaCodeType.Unknown;
}

/// <summary>
/// Converts from the area code value to enum type
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static QuestAreaCodeType ToEnum(int value)
{
if (Enum.IsDefined(typeof(QuestAreaCodeType), value))
{
return (QuestAreaCodeType)value;
}
else
{
//Console.WriteLine($"Warning: Invalid QuestAreaCodeType value {value}. Defaulting to Unknown.");
return QuestAreaCodeType.Unknown;
}
}
}
}

Expand Down

0 comments on commit d1ece85

Please sign in to comment.