public static void GetCurrencyData(string titleId, Action <bool, List <VirtualCurrencyData> > callback) { var currentPlayFabTitleId = PlayFabSettings.TitleId; var currentDevKey = PlayFabSettings.DeveloperSecretKey; var title = FindTitle(titleId); PlayFabSettings.TitleId = titleId; PlayFabSettings.DeveloperSecretKey = title.SecretKey; var task = PlayFabAdminAPI.ListVirtualCurrencyTypesAsync(new ListVirtualCurrencyTypesRequest()) .ContinueWith( (result) => { PlayFabSettings.TitleId = currentPlayFabTitleId; PlayFabSettings.DeveloperSecretKey = currentDevKey; if (result.Result.Error != null) { Console.WriteLine(PlayFabUtil.GetErrorReport(result.Result.Error)); callback(false, null); return; } if (result.IsCompleted) { callback(true, result.Result.Result.VirtualCurrencies); } }); }
async public static Task <ListVirtualCurrencyTypesResult> GetCurrencyData(string titleId) { var currentPlayFabTitleId = PlayFabSettings.TitleId; var currentDevKey = PlayFabSettings.DeveloperSecretKey; var title = FindTitle(titleId); PlayFabSettings.TitleId = titleId; PlayFabSettings.DeveloperSecretKey = title.SecretKey; // I want to return a task that holds the var result = await PlayFabAdminAPI.ListVirtualCurrencyTypesAsync(new ListVirtualCurrencyTypesRequest()); //.ContinueWith( // (result) => { // PlayFabSettings.TitleId = currentPlayFabTitleId; // PlayFabSettings.DeveloperSecretKey = currentDevKey; // if (result.Result.Error != null) // { // Console.WriteLine(PlayFabUtil.GetErrorReport(result.Result.Error)); // callback(false, null); // return; // } // if (result.IsCompleted) // { // callback(true, result.Result.Result.VirtualCurrencies); // } // }); PlayFabSettings.TitleId = currentPlayFabTitleId; PlayFabSettings.DeveloperSecretKey = currentDevKey; if (result.Error != null) { Console.WriteLine(PlayFabUtil.GetErrorReport(result.Error)); return(null); } Console.WriteLine("The data found in get currency " + result.Result.VirtualCurrencies.Count); return(result.Result); }