Skip to content

Commit

Permalink
[HUP-821] Fix: Fixed Enum.TryParse for lower C# versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
alihan98ersoy committed Feb 22, 2024
1 parent 87ce3c8 commit e0d5c9e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
15 changes: 5 additions & 10 deletions Assets/Huawei/Scripts/Game/HMSGameServiceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,19 +268,14 @@ public void OnUpdateInfo(AndroidIntent intent)
}
OnAppUpdateInfo?.Invoke(new OnAppUpdateInfoRes(status, rtnCode, rtnMessage, isExit, buttonStatus));

object statusCodeObj = status;
object rtnCodeObj = rtnCode;
object buttonStatusObj = buttonStatus;

if (Enum.TryParse(typeof(AppUpdateStatusCode), statusCodeObj.ToString(), out statusCodeObj) &&
Enum.TryParse(typeof(AppUpdateRtnCode), rtnCodeObj.ToString(), out rtnCodeObj) &&
Enum.TryParse(typeof(AppUpdateButtonStatus), buttonStatusObj.ToString(), out buttonStatusObj))
try
{
Debug.Log($"{TAG} OnUpdateInfo, status: {(AppUpdateStatusCode)statusCodeObj}, rtnCode: {(AppUpdateRtnCode)rtnCodeObj}, rtnMessage: {rtnMessage}, buttonStatus: {(AppUpdateButtonStatus)buttonStatusObj}, isExit: {isExit}");
Debug.Log($"{TAG} OnUpdateInfo, status: {(AppUpdateStatusCode)status}," +
$" rtnCode: {(AppUpdateRtnCode)rtnCode}, rtnMessage: {rtnMessage}, buttonStatus: {(AppUpdateButtonStatus)buttonStatus}, isExit: {isExit}");
}
else
catch(Exception e)
{
Debug.LogError($"{TAG} Failed to parse status, rtnCode, or buttonStatus as their respective enums");
Debug.LogError($"{TAG} Failed to parse status, rtnCode, or buttonStatus as their respective enums exception:{e.Message}");
}
}
public void OnMarketInstallInfo(AndroidIntent intent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public List<HMSIAPProductEntry> GetAllIAPProducts()

foreach (var key in _settings.Keys)
{
if (Enum.TryParse(typeof(HMSIAPProductType), _settings.Get(key), out var productType))
if (Enum.TryParse<HMSIAPProductType>(_settings.Get(key), out var productType))
{
returnList.Add(new HMSIAPProductEntry(key, (HMSIAPProductType)productType));
}
Expand Down

0 comments on commit e0d5c9e

Please sign in to comment.