private async Task <bool> TitleData(string parsedFile, CancellationToken token) { var titleDataDict = JsonWrapper.DeserializeObject <Dictionary <string, string> >(parsedFile); foreach (var kvp in titleDataDict) { if (IsCancellationRequest(token)) { return(false); } LogToFile("\tUploading: " + kvp.Key); var request = new SetTitleDataRequest() { Key = kvp.Key, Value = kvp.Value }; var setTitleDataTask = await PlayFabAdminAPI.SetTitleDataAsync(request); if (setTitleDataTask.Error != null) { OutputPlayFabError("\t\tTitleData Upload: " + kvp.Key, setTitleDataTask.Error); } else { LogToFile("\t\t" + kvp.Key + " Uploaded."); } } return(true); }
private void OnReceivedPlayStreamEvent(NetworkMessage netMsg) { var psEvent = netMsg.ReadMessage <PlayStreamEventMessage>(); if (psEvent == null) { return; } Debug.Log("there is a event"); var nobodycares = JsonWrapper.DeserializeObject <PlayerInventoryItemAddedEventData>(psEvent.EventData); if (nobodycares.EventName == "title_statistic_version_changed") { StartText.text = "New Tournament Season Begins!"; Invoke("ClearText", 6.0f); } else if (nobodycares.EventName == "player_inventory_item_added") { StartText.text = "You received " + nobodycares.DisplayName + "!"; Invoke("ClearText", 6.0f); } else if (nobodycares.EventName == "player_virtual_currency_balance_changed") { var vcevent = JsonWrapper.DeserializeObject <PlayerVirtualCurrencyBalanceChangedEventData>(psEvent.EventData); if (vcevent.VirtualCurrencyBalance == 0) { return; } StartText.text = "You Virtual Currency " + vcevent.VirtualCurrencyName + " just changed from " + vcevent.VirtualCurrencyPreviousBalance + " to " + vcevent.VirtualCurrencyBalance; Invoke("ClearText", 6.0f); } }
public void OtherSpecificDatatypes(UUnitTestContext testContext) { var expectedObj = new OtherSpecificDatatypes { StringDict = new Dictionary <string, string> { { "stringKey", "stringValue" } }, EnumDict = new Dictionary <string, Region> { { "enumKey", Region.Japan } }, IntDict = new Dictionary <string, int> { { "intKey", int.MinValue } }, UintDict = new Dictionary <string, uint> { { "uintKey", uint.MaxValue } }, TestString = "yup", }; // Convert the object to json and back, and verify that everything is the same var actualJson = JsonWrapper.SerializeObject(expectedObj, PlayFabUtil.ApiSerializerStrategy).Replace(" ", "").Replace("\n", "").Replace("\r", "").Replace("\t", ""); var actualObject = JsonWrapper.DeserializeObject <OtherSpecificDatatypes>(actualJson, PlayFabUtil.ApiSerializerStrategy); testContext.ObjEquals(expectedObj.TestString, actualObject.TestString); testContext.SequenceEquals(expectedObj.IntDict, actualObject.IntDict); testContext.SequenceEquals(expectedObj.UintDict, actualObject.UintDict); testContext.SequenceEquals(expectedObj.StringDict, actualObject.StringDict); testContext.SequenceEquals(expectedObj.EnumDict, actualObject.EnumDict); testContext.EndTest(UUnitFinishState.PASSED, null); }
public override void SetUp(UUnitTestContext testContext) { if (EXEC_ONCE) { Dictionary <string, string> testInputs; string filename = "C:/depot/pf-main/tools/SDKBuildScripts/testTitleData.json"; // TODO: Figure out how to not hard code this if (File.Exists(filename)) { string testInputsFile = PlayFabUtil.ReadAllFileText(filename); testInputs = JsonWrapper.DeserializeObject <Dictionary <string, string> >(testInputsFile, PlayFabUtil.ApiSerializerStrategy); } else { // NOTE FOR DEVELOPERS: if you want to run these tests, provide useful defaults, and uncomment this section, or provide a valid path to a "testTitleData.json" file above testInputs = new Dictionary <string, string>(); //Debug.LogError("Loading testSettings file failed: " + filename + ", loading defaults."); //testInputs["titleId"] = "your title id here"; //testInputs["titleCanUpdateSettings"] = "true"; // These tests require a GameManager setting: clients must be able to set stats and userData //testInputs["userName"] = "******"; //testInputs["userEmail"] = "*****@*****.**"; //testInputs["userPassword"] = "******"; } SetTitleInfo(testInputs); EXEC_ONCE = false; } if (!TITLE_INFO_SET) { testContext.Skip(); // We cannot do client tests if the titleId is not given } }
private async Task <bool> TitleNews(string parsedFile, CancellationToken token) { var titleNewsItems = JsonWrapper.DeserializeObject <List <PlayFab.ServerModels.TitleNewsItem> >(parsedFile); foreach (var item in titleNewsItems) { LogToFile("\tUploading: " + item.Title); var request = new AddNewsRequest() { Title = item.Title, Body = item.Body }; var addNewsTask = await PlayFabAdminAPI.AddNewsAsync(request); if (addNewsTask.Error != null) { OutputPlayFabError("\t\tTitleNews Upload: " + item.Title, addNewsTask.Error); } else { LogToFile("\t\t" + item.Title + " Uploaded."); } } return(true); }
private static bool UploadCdnAssets() { if (string.IsNullOrEmpty(cdnAssetsPath)) { return(false); } LogToFile("Uploading CDN AssetBundles..."); var parsedFile = ParseFile(cdnAssetsPath); var assetData = JsonWrapper.DeserializeObject <List <CdnAssetData> >(parsedFile); if (assetData != null) { foreach (var item in assetData) { string key = string.Format("{0}{1}/{2}", item.Platform == "Desktop" ? "" : item.Platform + "/", item.Key, item.Name); string path = item.Path + item.Name; UploadAsset(key, path); } } else { LogToFile("\tAn error occurred deserializing CDN Assets: ", ConsoleColor.Red); return(false); } return(true); }
private static void OnWwwSuccess <TResultType>(string api, Action <TResultType> resultCallback, Action <PlayFab.PfEditor.EditorModels.PlayFabError> errorCallback, string response) where TResultType : class { var httpResult = JsonWrapper.DeserializeObject <HttpResponseObject>(response, PlayFabEditorUtil.ApiSerializerStrategy); if (httpResult.code != 200) { OnWwwError(errorCallback, response); return; } PlayFabEditor.RaiseStateUpdate(PlayFabEditor.EdExStates.OnHttpRes, api); if (resultCallback == null) { return; } TResultType result = null; var resultAssigned = false; var dataJson = JsonWrapper.SerializeObject(httpResult.data, PlayFabEditorUtil.ApiSerializerStrategy); result = JsonWrapper.DeserializeObject <TResultType>(dataJson, PlayFabEditorUtil.ApiSerializerStrategy); resultAssigned = true; if (resultAssigned) { resultCallback(result); } }
protected internal static PlayFabError GeneratePlayFabError(string json, object customData = null) { //deserialize the error var errorDict = JsonWrapper.DeserializeObject <JsonObject>(json, PlayFabUtil.ApiSerializerStrategy); Dictionary <string, List <string> > errorDetails = null; if (errorDict.ContainsKey("errorDetails")) { errorDetails = JsonWrapper.DeserializeObject <Dictionary <string, List <string> > >(errorDict["errorDetails"].ToString()); } //create new error object return(new PlayFabError { HttpCode = errorDict.ContainsKey("code") ? Convert.ToInt32(errorDict["code"]) : 400, HttpStatus = errorDict.ContainsKey("status") ? (string)errorDict["status"] : "BadRequest", Error = errorDict.ContainsKey("errorCode") ? (PlayFabErrorCode)Convert.ToInt32(errorDict["errorCode"]) : PlayFabErrorCode.ServiceUnavailable, ErrorMessage = errorDict.ContainsKey("errorMessage") ? (string)errorDict["errorMessage"] : string.Empty, ErrorDetails = errorDetails, CustomData = customData ?? new object() }); }
public async Task <bool> UploadCdnAssets() { if (string.IsNullOrEmpty(cdnAssetsPath)) { LogToFile("CDN AssetBundles File Path is Null "); return(true); } LogToFile("Uploading CDN AssetBundles..."); var parsedFile = ParseFile(cdnAssetsPath); var bundleNames = JsonWrapper.DeserializeObject <List <string> >( parsedFile); // TODO: This could probably just read the list of files from the directory if (bundleNames != null) { foreach (var bundleName in bundleNames) { foreach (CdnPlatform eachPlatform in Enum.GetValues(typeof(CdnPlatform))) { var key = cdnPlatformSubfolder[eachPlatform] + bundleName; var path = cdnPath + key; await UploadAsset(key, path); } } } else { LogToFile("\tAn error occurred deserializing CDN Assets: ", ConsoleColor.Red); return(false); } return(true); }
public void SerializeExample(UUnitTestContext testContext) { TestSuiteReport[] actualSuites = JsonWrapper.DeserializeObject <TestSuiteReport[]>(EXAMPLE_JSON); testContext.NotNull(actualSuites); foreach (var expectedTestName in EXPECTED_TESTS) { var testFound = false; foreach (var suite in actualSuites) { foreach (var test in suite.testResults) { if (test.name == expectedTestName) { testFound = true; break; } } testContext.IntEquals(suite.tests, EXPECTED_TESTS.Length, "Total tests does not match expected {0}, {1}"); } testContext.True(testFound, "Test not found: " + expectedTestName); } testContext.EndTest(UUnitFinishState.PASSED, null); }
private static bool UploadEventData() { if (string.IsNullOrEmpty(catalogPathEvents)) { return(false); } LogToFile("Uploading Event Items..."); var parsedFile = ParseFile(catalogPathEvents); var catalogWrapper = JsonWrapper.DeserializeObject <CatalogWrapper>(parsedFile); if (catalogWrapper == null) { LogToFile("\tAn error occurred deserializing the CatalogEvents.json file.", ConsoleColor.Red); return(false); } if (!UpdateCatalog(catalogWrapper.Catalog, "Events", false)) { return(false); } LogToFile("\tUploaded Event Catalog!", ConsoleColor.Green); if (!UploadStores(storesPathEvents, "Events")) { return(false); } return(true); }
private static bool UploadPolicy(string filePath) { if (string.IsNullOrEmpty(filePath)) { return(false); } LogToFile("Uploading Policy..."); var parsedFile = ParseFile(filePath); var permissionList = JsonWrapper.DeserializeObject <List <PlayFab.ProfilesModels.EntityPermissionStatement> >(parsedFile); var request = new PlayFab.ProfilesModels.SetGlobalPolicyRequest { Permissions = permissionList }; var setPermissionTask = PlayFab.PlayFabProfilesAPI.SetGlobalPolicyAsync(request); setPermissionTask.Wait(); if (setPermissionTask.Result.Error != null) { OutputPlayFabError("\t\tSet Permissions: ", setPermissionTask.Result.Error); } else { LogToFile("\t\tPermissions uploaded... ", ConsoleColor.Green); } return(true); }
private static TestTitleData GetTestTitleData(string[] args) { TestTitleData testInputs = null; string filename = null; for (var i = 0; i < args.Length; i++) { if (args[i] == "-testInputsFile" && (i + 1) < args.Length) { filename = args[i + 1]; } } if (string.IsNullOrEmpty(filename)) { filename = Environment.GetEnvironmentVariable("PF_TEST_TITLE_DATA_JSON"); } if (File.Exists(filename)) { var testInputsFile = File.ReadAllText(filename); testInputs = JsonWrapper.DeserializeObject <TestTitleData>(testInputsFile); } else { WriteConsoleColor("Loading testSettings file failed: " + filename, ConsoleColor.Red); WriteConsoleColor("From: " + Directory.GetCurrentDirectory(), ConsoleColor.Red); } return(testInputs); }
protected internal static PlayFabError GeneratePlayFabError(string apiEndpoint, string json, object customData) { JsonObject jsonObject = null; Dictionary <string, List <string> > errorDetails = null; try { jsonObject = JsonWrapper.DeserializeObject <JsonObject>(json); } catch (Exception) { } try { if (jsonObject != null && jsonObject.ContainsKey("errorDetails")) { errorDetails = JsonWrapper.DeserializeObject <Dictionary <string, List <string> > >(jsonObject["errorDetails"].ToString()); } } catch (Exception) { } return(new PlayFabError { ApiEndpoint = apiEndpoint, HttpCode = ((jsonObject == null || !jsonObject.ContainsKey("code")) ? 400 : Convert.ToInt32(jsonObject["code"])), HttpStatus = ((jsonObject == null || !jsonObject.ContainsKey("status")) ? "BadRequest" : ((string)jsonObject["status"])), Error = (PlayFabErrorCode)((jsonObject == null || !jsonObject.ContainsKey("errorCode")) ? 1123 : Convert.ToInt32(jsonObject["errorCode"])), ErrorMessage = ((jsonObject == null || !jsonObject.ContainsKey("errorMessage")) ? json : ((string)jsonObject["errorMessage"])), ErrorDetails = errorDetails, CustomData = customData }); }
/// <summary> /// Informs the PlayFab game server hosting service that the indicated user has left the Game Server Instance specified /// </summary> public static async Task <PlayFabResult <PlayerLeftResponse> > PlayerLeftAsync(PlayerLeftRequest request, object customData = null) { if (PlayFabSettings.DeveloperSecretKey == null) { throw new Exception("Must have PlayFabSettings.DeveloperSecretKey set to call this method"); } var httpResult = await PlayFabHttp.DoPost("/Matchmaker/PlayerLeft", request, "X-SecretKey", PlayFabSettings.DeveloperSecretKey); if (httpResult is PlayFabError) { var error = (PlayFabError)httpResult; if (PlayFabSettings.GlobalErrorHandler != null) { PlayFabSettings.GlobalErrorHandler(error); } return(new PlayFabResult <PlayerLeftResponse> { Error = error, CustomData = customData }); } var resultRawJson = (string)httpResult; var resultData = JsonWrapper.DeserializeObject <PlayFabJsonSuccess <PlayerLeftResponse> >(resultRawJson); var result = resultData.data; return(new PlayFabResult <PlayerLeftResponse> { Result = result, CustomData = customData }); }
private async Task <bool> Stores(string parsedFile, CancellationToken token) { var storesList = JsonWrapper.DeserializeObject <List <StoreWrapper> >(parsedFile); foreach (var eachStore in storesList) { if (IsCancellationRequest(token)) { return(false); } LogToFile("\tUploading: " + eachStore.StoreId); var request = new UpdateStoreItemsRequest { CatalogVersion = defaultCatalog, StoreId = eachStore.StoreId, Store = eachStore.Store, MarketingData = eachStore.MarketingData }; var updateStoresTask = await PlayFabAdminAPI.SetStoreItemsAsync(request); if (updateStoresTask.Error != null) { OutputPlayFabError("\t\tStore Upload: " + eachStore.StoreId, updateStoresTask.Error); } else { LogToFile("\t\tStore: " + eachStore.StoreId + " Uploaded. "); } } return(true); }
private async Task <bool> CDNAssets(string parsedFile, CancellationToken token) { var bundleNames = JsonWrapper.DeserializeObject <List <string> >(parsedFile); // TODO: This could probably just read the list of files from the directory if (bundleNames != null) { foreach (var bundleName in bundleNames) { if (IsCancellationRequest(token)) { return(false); } foreach (CdnPlatform eachPlatform in Enum.GetValues(typeof(CdnPlatform))) { var key = cdnPlatformSubfolder[eachPlatform] + bundleName; var path = cdnPath + key; await UploadAssetAsync(key, path, token); } } } else { LogToFile("\tAn error occurred deserializing CDN Assets: "); return(false); } return(true); }
public async Task <bool> UploadVc() { LogToFile("Uploading Virtual Currency Settings..."); if (string.IsNullOrEmpty(currencyPath)) { LogToFile("irtual Currency Settings File Path is Null "); return(true); } var parsedFile = ParseFile(currencyPath); var vcData = JsonWrapper.DeserializeObject <List <VirtualCurrencyData> >(parsedFile); var request = new AddVirtualCurrencyTypesRequest { VirtualCurrencies = vcData }; if (token.IsCancellationRequested) { return(true); } var updateVcTask = await PlayFabAdminAPI.AddVirtualCurrencyTypesAsync(request); //updateVcTask.Wait(); if (updateVcTask.Error != null) { OutputPlayFabError("\tVC Upload Error: ", updateVcTask.Error); return(false); } LogToFile("\tUploaded VC!", ConsoleColor.Green); return(true); }
internal static void MakeGitHubApiCall(string url, Action <string> resultCallback) { var www = new WWW(url); EditorCoroutine.start(Post(www, (response) => { List <System.Object> jsonResponse = JsonWrapper.DeserializeObject <List <System.Object> >(response); // list seems to come back in ascending order (oldest -> newest) if (jsonResponse != null && jsonResponse.Count > 0) { JsonObject latestSdkTag = (JsonObject)jsonResponse[jsonResponse.Count - 1]; object tag; if (latestSdkTag.TryGetValue("ref", out tag)) { if (resultCallback != null) { int startIndex = tag.ToString().LastIndexOf('/') + 1; int length = tag.ToString().Length - startIndex; resultCallback(tag.ToString().Substring(startIndex, length)); } } else { if (resultCallback != null) { resultCallback(null); } } return; } }, PlayFabEditorHelper.SharedErrorCallback), www); }
public async Task <bool> UploadCatalog(List <CatalogItem> reUploadList) { if (string.IsNullOrEmpty(catalogPath)) { LogToFile("CatalogItems File Path is Null "); return(true); } LogToFile("Uploading CatalogItems..."); var parsedFile = ParseFile(catalogPath); var catalogWrapper = JsonWrapper.DeserializeObject <CatalogWrapper>(parsedFile); if (catalogWrapper == null) { LogToFile("\tAn error occurred deserializing the Catalog.json file.", ConsoleColor.Red); return(false); } for (var z = 0; z < catalogWrapper.Catalog.Count; z++) { if (catalogWrapper.Catalog[z].Bundle != null || catalogWrapper.Catalog[z].Container != null) { var original = catalogWrapper.Catalog[z]; var strippedClone = CloneCatalogItemAndStripTables(original); reUploadList.Add(original); catalogWrapper.Catalog.Remove(original); catalogWrapper.Catalog.Add(strippedClone); } } return(await UpdateCatalog(catalogWrapper.Catalog)); }
void JsonTimeStampHandlesAllFormats(UUnitTestContext testContext) { string expectedJson, actualJson; DateTime expectedTime; ObjWithTimes actualObj = new ObjWithTimes(); for (int i = 0; i < _examples.Length; i++) { // Define the time deserialization expectation testContext.True(DateTime.TryParseExact(_examples[i], PlayFabUtil._defaultDateTimeFormats, CultureInfo.CurrentCulture, DateTimeStyles.RoundtripKind, out expectedTime), "Index: " + i + "/" + _examples.Length + ", " + _examples[i]); // De-serialize the time using json expectedJson = "{\"timestamp\":\"" + _examples[i] + "\"}"; // We are provided a json string with every random time format actualObj = JsonWrapper.DeserializeObject <ObjWithTimes>(expectedJson, PlayFabUtil.ApiSerializerStrategy); actualJson = JsonWrapper.SerializeObject(actualObj, PlayFabUtil.ApiSerializerStrategy); if (i == PlayFabUtil.DEFAULT_UTC_OUTPUT_INDEX) // This is the only case where the json input will match the json output { testContext.StringEquals(expectedJson, actualJson); } // Verify that the times match double diff = (expectedTime - actualObj.timestamp).TotalSeconds; // We expect that we have parsed the time correctly according to expectations testContext.True(diff < 1, "\nActual time: " + actualObj.timestamp + " vs Expected time: " + expectedTime + ", diff: " + diff + "\nActual json: " + actualJson + " vs Expected json: " + expectedJson ); } testContext.EndTest(UUnitFinishState.PASSED, null); }
public override void SetUp(UUnitTestContext testContext) { if (_execOnce) { Dictionary <string, string> testInputs; if (File.Exists(TitleDataFilename)) { var testInputsFile = PlayFabUtil.ReadAllFileText(TitleDataFilename); testInputs = JsonWrapper.DeserializeObject <Dictionary <string, string> >(testInputsFile, PlayFabUtil.ApiSerializerStrategy); } else { // NOTE FOR DEVELOPERS: if you want to run these tests, provide useful defaults, and uncomment this section, or provide a valid path to a "testTitleData.json" file above testInputs = new Dictionary <string, string>(); //Debug.LogError("Loading testSettings file failed: " + filename + ", loading defaults."); //testInputs["titleId"] = "your title id here"; //testInputs["developerSecretKey"] = "your secret key here"; // BE VERY CAREFUL NOT TO PUBLISH THIS, or build it into a client } SetTitleInfo(testInputs); _execOnce = false; } if (!_titleInfoSet) { testContext.Skip(); // We cannot do client tests if the titleId is not given } }
public static string GetIconByItemById(string catalogItemId, string iconDefault = "Default") { var catalogItem = GetCatalogItemById(catalogItemId); if (catalogItem == null) { return(null); } var iconName = iconDefault; try { string temp; var kvps = JsonWrapper.DeserializeObject <Dictionary <string, string> >(catalogItem.CustomData); if (kvps != null && kvps.TryGetValue("icon", out temp)) { iconName = temp; } } catch (Exception e) { Debug.LogException(e); } return(iconName); }
protected internal static PlayFabError GeneratePlayFabError(string apiEndpoint, string json, object customData) { JsonObject errorDict = null; Dictionary <string, List <string> > errorDetails = null; try { // Deserialize the error errorDict = JsonWrapper.DeserializeObject <JsonObject>(json); } catch (Exception) { /* Unusual, but shouldn't actually matter */ } try { if (errorDict != null && errorDict.ContainsKey("errorDetails")) { errorDetails = JsonWrapper.DeserializeObject <Dictionary <string, List <string> > >(errorDict["errorDetails"].ToString()); } } catch (Exception) { /* Unusual, but shouldn't actually matter */ } return(new PlayFabError { ApiEndpoint = apiEndpoint, HttpCode = errorDict != null && errorDict.ContainsKey("code") ? Convert.ToInt32(errorDict["code"]) : 400, HttpStatus = errorDict != null && errorDict.ContainsKey("status") ? (string)errorDict["status"] : "BadRequest", Error = errorDict != null && errorDict.ContainsKey("errorCode") ? (PlayFabErrorCode)Convert.ToInt32(errorDict["errorCode"]) : PlayFabErrorCode.ServiceUnavailable, ErrorMessage = errorDict != null && errorDict.ContainsKey("errorMessage") ? (string)errorDict["errorMessage"] : json, ErrorDetails = errorDetails, CustomData = customData }); }
public override void SetUp(UUnitTestContext testContext) { if (EXEC_ONCE) { Dictionary <string, string> testInputs; string filename = "C:/depot/pf-main/tools/SDKBuildScripts/testTitleData.json"; // TODO: Figure out how to not hard code this if (File.Exists(filename)) { string testInputsFile = PlayFabUtil.ReadAllFileText(filename); testInputs = JsonWrapper.DeserializeObject <Dictionary <string, string> >(testInputsFile, PlayFabUtil.ApiSerializerStrategy); } else { Debug.LogError("Loading testSettings file failed: " + filename + ", loading defaults."); testInputs = new Dictionary <String, String>(); testInputs["titleId"] = "6195"; testInputs["titleCanUpdateSettings"] = "true"; testInputs["userName"] = "******"; testInputs["userEmail"] = "*****@*****.**"; testInputs["userPassword"] = "******"; } SetTitleInfo(testInputs); EXEC_ONCE = false; } if (!TITLE_INFO_SET) { testContext.Skip(); // We cannot do client tests if the titleId is not given } }
private static void OnGitHubSuccess(Action <string> resultCallback, string response) { if (resultCallback == null) { return; } var jsonResponse = JsonWrapper.DeserializeObject <List <object> >(response); if (jsonResponse == null || jsonResponse.Count == 0) { return; } // list seems to come back in ascending order (oldest -> newest) var latestSdkTag = (JsonObject)jsonResponse[jsonResponse.Count - 1]; object tag; if (latestSdkTag.TryGetValue("ref", out tag)) { var startIndex = tag.ToString().LastIndexOf('/') + 1; var length = tag.ToString().Length - startIndex; resultCallback(tag.ToString().Substring(startIndex, length)); } else { resultCallback(null); } }
private static bool UploadCatalog(ref List <CatalogItem> reUploadList) { if (string.IsNullOrEmpty(catalogPath)) { return(false); } LogToFile("Uploading CatalogItems..."); var parsedFile = ParseFile(catalogPath); var catalogItems = JsonWrapper.DeserializeObject <List <CatalogItem> >(parsedFile); if (catalogItems == null) { LogToFile("\tAn error occurred deserializing the Catalog.json file.", ConsoleColor.Red); return(false); } for (var z = 0; z < catalogItems.Count; z++) { if (catalogItems[z].Bundle != null || catalogItems[z].Container != null) { var original = catalogItems[z]; var strippedClone = CloneCatalogItemAndStripTables(original); reUploadList.Add(original); catalogItems.Remove(original); catalogItems.Add(strippedClone); } } return(UpdateCatalog(catalogItems)); }
private async Task <bool> StatisticDefination(string parsedFile, CancellationToken token) { var statisticDefinitions = JsonWrapper.DeserializeObject <List <PlayerStatisticDefinition> >(parsedFile); foreach (var item in statisticDefinitions) { if (IsCancellationRequest(token)) { return(false); } LogToFile("\tUploading: " + item.StatisticName); var request = new CreatePlayerStatisticDefinitionRequest() { StatisticName = item.StatisticName, VersionChangeInterval = item.VersionChangeInterval, AggregationMethod = item.AggregationMethod }; var createStatTask = await PlayFabAdminAPI.CreatePlayerStatisticDefinitionAsync(request); if (createStatTask.Error != null) { if (createStatTask.Error.Error == PlayFabErrorCode.StatisticNameConflict) { LogToFile("\tStatistic Already Exists, Updating values: " + item.StatisticName); var updateRequest = new UpdatePlayerStatisticDefinitionRequest() { StatisticName = item.StatisticName, VersionChangeInterval = item.VersionChangeInterval, AggregationMethod = item.AggregationMethod }; if (IsCancellationRequest(token)) { return(false); } var updateStatTask = await PlayFabAdminAPI.UpdatePlayerStatisticDefinitionAsync(updateRequest); if (updateStatTask.Error != null) { OutputPlayFabError("\t\tStatistics Definition Error: " + item.StatisticName, updateStatTask.Error); } else { LogToFile("\t\tStatistics Definition:" + item.StatisticName + " Updated"); } } else { OutputPlayFabError("\t\tStatistics Definition Error: " + item.StatisticName, createStatTask.Error); } } else { LogToFile("\t\tStatistics Definition: " + item.StatisticName + " Created"); } } return(true); }
public override void Deserialize(NetworkReader reader) { ChannelId = reader.ReadString(); SenderUserId = reader.ReadString(); SenderUserName = reader.ReadString(); Message = reader.ReadString(); Timestamp = JsonWrapper.DeserializeObject <DateTime>(reader.ReadString()); }
public static string DeserializePictureURLString(string response) { Dictionary <string, FB_PhotoResponse> result = JsonWrapper.DeserializeObject <Dictionary <string, FB_PhotoResponse> >(response); FB_PhotoResponse urlH; result.TryGetValue("data", out urlH); return(urlH == null ? null : urlH.url); }