/// <summary> /// Initialises a new instance from the given Json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the Json data.</param> public MessageRewardRedeemed(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Currencies"), "Json is missing required field 'Currencies'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Items"), "Json is missing required field 'Items'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Currencies if (entry.Key == "Currencies") { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); Currencies = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is IDictionary <string, object>, "Invalid element type."); return(new MessageRewardRedeemedCurrency((IDictionary <string, object>)element)); }); } // Items else if (entry.Key == "Items") { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); Items = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is IDictionary <string, object>, "Invalid element type."); return(new MessageRewardRedeemedInventory((IDictionary <string, object>)element)); }); } } }
/// <summary> /// Initialises the response with the given json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the JSON data.</param> public GetCurrencyBalanceResponse(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("EconomyVersion"), "Json is missing required field 'EconomyVersion'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Balances"), "Json is missing required field 'Balances'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Economy Version if (entry.Key == "EconomyVersion") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); EconomyVersion = (string)entry.Value; } // Balances else if (entry.Key == "Balances") { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); Balances = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is IDictionary <string, object>, "Invalid element type."); return(new CurrencyBalance((IDictionary <string, object>)element)); }); } } }
/// <summary> /// Initialises the response with the given json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the JSON data.</param> public GetInventoryForKeysResponse(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("CatalogVersion"), "Json is missing required field 'CatalogVersion'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Items"), "Json is missing required field 'Items'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Catalog Version if (entry.Key == "CatalogVersion") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); CatalogVersion = (string)entry.Value; } // Items else if (entry.Key == "Items") { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); Items = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is IDictionary <string, object>, "Invalid element type."); return(new PlayerInventoryItem((IDictionary <string, object>)element)); }); } } }
/// <summary> /// Initialises the response with the given json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the JSON data.</param> public GetMatchTurnsResponse(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Turns"), "Json is missing required field 'Turns'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Total"), "Json is missing required field 'Total'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Turns if (entry.Key == "Turns") { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); Turns = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is IDictionary <string, object>, "Invalid element type."); return(new MatchTurn((IDictionary <string, object>)element)); }); } // Total else if (entry.Key == "Total") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); Total = (int)(long)entry.Value; } } }
/// <summary> /// Initialises the response with the given json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the JSON data.</param> public LookupFacebookPlayersResponse(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Players"), "Json is missing required field 'Players'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Players if (entry.Key == "Players") { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); Players = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is IDictionary <string, object>, "Invalid element type."); return(new FacebookPlayer((IDictionary <string, object>)element)); }); } // An error has occurred. else { #if DEBUG throw new ArgumentException("Input Json contains an invalid field."); #endif } } }
/// <summary> /// Initialises the response with the given json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the JSON data.</param> public GetScoresAroundPlayerResponse(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Page"), "Json is missing required field 'Page'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Rank"), "Json is missing required field 'Rank'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Index"), "Json is missing required field 'Index'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("PageSize"), "Json is missing required field 'PageSize'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Total"), "Json is missing required field 'Total'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Scores"), "Json is missing required field 'Scores'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Page if (entry.Key == "Page") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); Page = (int)(long)entry.Value; } // Rank else if (entry.Key == "Rank") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); Rank = (int)(long)entry.Value; } // Index else if (entry.Key == "Index") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); Index = (int)(long)entry.Value; } // Page Size else if (entry.Key == "PageSize") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); PageSize = (int)(long)entry.Value; } // Total else if (entry.Key == "Total") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); Total = (int)(long)entry.Value; } // Scores else if (entry.Key == "Scores") { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); Scores = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is IDictionary <string, object>, "Invalid element type."); return(new GlobalScore((IDictionary <string, object>)element)); }); } } }
/// <summary> /// Initialises a new instance from the given Json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the Json data.</param> public ConversionDefinition(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Key"), "Json is missing required field 'Key'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Name"), "Json is missing required field 'Name'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Tags"), "Json is missing required field 'Tags'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Rules"), "Json is missing required field 'Rules'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Key if (entry.Key == "Key") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Key = (string)entry.Value; } // Name else if (entry.Key == "Name") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Name = (string)entry.Value; } // Tags else if (entry.Key == "Tags") { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); Tags = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is string, "Invalid element type."); return((string)element); }); } // Custom Data else if (entry.Key == "CustomData") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is object, "Invalid serialised type."); CustomData = new MultiTypeValue((object)entry.Value); } } // Rules else if (entry.Key == "Rules") { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); Rules = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is IDictionary <string, object>, "Invalid element type."); return(new ConversionRuleDefinition((IDictionary <string, object>)element)); }); } } }
/// <summary> /// Initialises a new instance from the given Json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the Json data.</param> public MetadataDefinition(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Key"), "Json is missing required field 'Key'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Name"), "Json is missing required field 'Name'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Tags"), "Json is missing required field 'Tags'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Key if (entry.Key == "Key") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Key = (string)entry.Value; } // Name else if (entry.Key == "Name") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Name = (string)entry.Value; } // Tags else if (entry.Key == "Tags") { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); Tags = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is string, "Invalid element type."); return((string)element); }); } // Custom Data else if (entry.Key == "CustomData") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is object, "Invalid serialised type."); CustomData = new MultiTypeValue((object)entry.Value); } } // An error has occurred. else { #if DEBUG throw new ArgumentException("Input Json contains an invalid field."); #endif } } }
/// <summary> /// Initialises the response with the given json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the JSON data.</param> public GetDefinitionsPackageResponse(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Version"), "Json is missing required field 'Version'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Url"), "Json is missing required field 'Url'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Size"), "Json is missing required field 'Size'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Checksum"), "Json is missing required field 'Checksum'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Files"), "Json is missing required field 'Files'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Version if (entry.Key == "Version") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Version = (string)entry.Value; } // Url else if (entry.Key == "Url") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Url = (string)entry.Value; } // Size else if (entry.Key == "Size") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); Size = (int)(long)entry.Value; } // Checksum else if (entry.Key == "Checksum") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Checksum = (string)entry.Value; } // Files else if (entry.Key == "Files") { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); Files = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is IDictionary <string, object>, "Invalid element type."); return(new EconomyPackageFile((IDictionary <string, object>)element)); }); } } }
/// <summary> /// Initialises a new instance from the given Json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the Json data.</param> public EconomyPackageFile(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Name"), "Json is missing required field 'Name'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Location"), "Json is missing required field 'Location'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Size"), "Json is missing required field 'Size'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Checksum"), "Json is missing required field 'Checksum'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Items"), "Json is missing required field 'Items'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Name if (entry.Key == "Name") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Name = (string)entry.Value; } // Location else if (entry.Key == "Location") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Location = (string)entry.Value; } // Size else if (entry.Key == "Size") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); Size = (int)(long)entry.Value; } // Checksum else if (entry.Key == "Checksum") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Checksum = (string)entry.Value; } // Items else if (entry.Key == "Items") { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); Items = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is IDictionary <string, object>, "Invalid element type."); return(new EconomyPackageFileItem((IDictionary <string, object>)element)); }); } } }
/// <summary> /// Initialises the response with the given json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the JSON data.</param> public GetVirtualPurchaseDefinitionsResponse(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("CatalogVersion"), "Json is missing required field 'CatalogVersion'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Items"), "Json is missing required field 'Items'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Total"), "Json is missing required field 'Total'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Page"), "Json is missing required field 'Page'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("PageSize"), "Json is missing required field 'PageSize'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Catalog Version if (entry.Key == "CatalogVersion") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); CatalogVersion = (string)entry.Value; } // Items else if (entry.Key == "Items") { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); Items = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is IDictionary <string, object>, "Invalid element type."); return(new VirtualPurchaseDefinition((IDictionary <string, object>)element)); }); } // Total else if (entry.Key == "Total") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); Total = (int)(long)entry.Value; } // Page else if (entry.Key == "Page") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); Page = (int)(long)entry.Value; } // Page Size else if (entry.Key == "PageSize") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); PageSize = (int)(long)entry.Value; } } }
/// <summary> /// Initialises the response with the given json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the JSON data.</param> public GetMessagesResponse(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Messages"), "Json is missing required field 'Messages'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Page"), "Json is missing required field 'Page'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("PageSize"), "Json is missing required field 'PageSize'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Total"), "Json is missing required field 'Total'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Messages if (entry.Key == "Messages") { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); Messages = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is IDictionary <string, object>, "Invalid element type."); return(new Message((IDictionary <string, object>)element)); }); } // Page else if (entry.Key == "Page") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); Page = (int)(long)entry.Value; } // Page Size else if (entry.Key == "PageSize") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); PageSize = (int)(long)entry.Value; } // Total else if (entry.Key == "Total") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); Total = (int)(long)entry.Value; } // An error has occurred. else { #if DEBUG throw new ArgumentException("Input Json contains an invalid field."); #endif } } }
/// <summary> /// Initialises a new instance from the given Json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the Json data.</param> public PurchaseInventoryExchange(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Name"), "Json is missing required field 'Name'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Key"), "Json is missing required field 'Key'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Amount"), "Json is missing required field 'Amount'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("ItemIDs"), "Json is missing required field 'ItemIDs'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Name if (entry.Key == "Name") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Name = (string)entry.Value; } // Key else if (entry.Key == "Key") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Key = (string)entry.Value; } // Amount else if (entry.Key == "Amount") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); Amount = (int)(long)entry.Value; } // Item Ids else if (entry.Key == "ItemIDs") { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); ItemIds = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is string, "Invalid element type."); return((string)element); }); } // An error has occurred. else { #if DEBUG throw new ArgumentException("Input Json contains an invalid field."); #endif } } }
/// <summary> /// Initialises the response with the given json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the JSON data.</param> public GetCollectionObjectsResponse(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Objects"), "Json is missing required field 'Objects'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Objects if (entry.Key == "Objects") { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); Objects = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is IDictionary <string, object>, "Invalid element type."); return(new CollectionDataObject((IDictionary <string, object>)element)); }); } } }
/// <summary> /// Initialises the response with the given json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the JSON data.</param> public LookupFacebookPlayersResponse(IDictionary<string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Players"), "Json is missing required field 'Players'"); foreach (KeyValuePair<string, object> entry in jsonDictionary) { // Players if (entry.Key == "Players") { ReleaseAssert.IsTrue(entry.Value is IList<object>, "Invalid serialised type."); Players = JsonSerialisation.DeserialiseList((IList<object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is IDictionary<string, object>, "Invalid element type."); return new FacebookPlayer((IDictionary<string, object>)element); }); } } }
/// <summary> /// Initialises the response with the given json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the JSON data.</param> public QueryCollectionResponse(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Objects"), "Json is missing required field 'Objects'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Total"), "Json is missing required field 'Total'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Page"), "Json is missing required field 'Page'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("PageSize"), "Json is missing required field 'PageSize'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Objects if (entry.Key == "Objects") { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); Objects = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is IDictionary <string, object>, "Invalid element type."); return(new CollectionDataObject((IDictionary <string, object>)element)); }); } // Total else if (entry.Key == "Total") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); Total = (int)(long)entry.Value; } // Page else if (entry.Key == "Page") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); Page = (int)(long)entry.Value; } // Page Size else if (entry.Key == "PageSize") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); PageSize = (int)(long)entry.Value; } } }
/// <summary> /// Initialises the response with the given json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the JSON data.</param> public GetScoresForFacebookFriendsResponse(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Scores"), "Json is missing required field 'Scores'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Scores if (entry.Key == "Scores") { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); Scores = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is IDictionary <string, object>, "Invalid element type."); return(new FacebookScore((IDictionary <string, object>)element)); }); } } }
/// <summary> /// Initialises the response with the given json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the JSON data.</param> public GetActiveCampaignsResponse(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("PermanentOverrides"), "Json is missing required field 'PermanentOverrides'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("ScheduledEvents"), "Json is missing required field 'ScheduledEvents'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Test if (entry.Key == "Test") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type."); Test = new AssignedTest((IDictionary <string, object>)entry.Value); } } // Permanent Overrides else if (entry.Key == "PermanentOverrides") { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); PermanentOverrides = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is IDictionary <string, object>, "Invalid element type."); return(new PermanentOverride((IDictionary <string, object>)element)); }); } // Scheduled Events else if (entry.Key == "ScheduledEvents") { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); ScheduledEvents = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is IDictionary <string, object>, "Invalid element type."); return(new ScheduledEvent((IDictionary <string, object>)element)); }); } } }
/// <summary> /// Initialises a new instance from the given Json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the Json data.</param> public MessageGifts(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Currencies"), "Json is missing required field 'Currencies'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Items"), "Json is missing required field 'Items'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Currencies if (entry.Key == "Currencies") { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); Currencies = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is IDictionary <string, object>, "Invalid element type."); return(new MessageSendCurrency((IDictionary <string, object>)element)); }); } // Items else if (entry.Key == "Items") { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); Items = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is IDictionary <string, object>, "Invalid element type."); return(new MessageSendInventory((IDictionary <string, object>)element)); }); } // An error has occurred. else { #if DEBUG throw new ArgumentException("Input Json contains an invalid field."); #endif } } }
/// <summary> /// Initialises the response with the given json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the JSON data.</param> public GetPlayerDetailsResponse(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("ChilliConnectID"), "Json is missing required field 'ChilliConnectID'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Chilli Connect Id if (entry.Key == "ChilliConnectID") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); ChilliConnectId = (string)entry.Value; } // User Name else if (entry.Key == "UserName") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); UserName = (string)entry.Value; } } // Display Name else if (entry.Key == "DisplayName") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); DisplayName = (string)entry.Value; } } // Email else if (entry.Key == "Email") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Email = (string)entry.Value; } } // Country else if (entry.Key == "Country") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Country = (string)entry.Value; } } // Device Model else if (entry.Key == "DeviceModel") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); DeviceModel = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is string, "Invalid element type."); return((string)element); }); } } // Device Type else if (entry.Key == "DeviceType") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); DeviceType = (string)entry.Value; } } // Platform else if (entry.Key == "Platform") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Platform = (string)entry.Value; } } } }
/// <summary> /// Initialises a new instance from the given Json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the Json data.</param> public RealMoneyPurchaseDefinition(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Key"), "Json is missing required field 'Key'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Name"), "Json is missing required field 'Name'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Tags"), "Json is missing required field 'Tags'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("AmazonID"), "Json is missing required field 'AmazonID'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("GoogleID"), "Json is missing required field 'GoogleID'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("IosID"), "Json is missing required field 'IosID'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Rewards"), "Json is missing required field 'Rewards'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Key if (entry.Key == "Key") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Key = (string)entry.Value; } // Name else if (entry.Key == "Name") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Name = (string)entry.Value; } // Tags else if (entry.Key == "Tags") { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); Tags = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is string, "Invalid element type."); return((string)element); }); } // Custom Data else if (entry.Key == "CustomData") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is object, "Invalid serialised type."); CustomData = new MultiTypeValue((object)entry.Value); } } // Amazon Id else if (entry.Key == "AmazonID") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); AmazonId = (string)entry.Value; } // Google Id else if (entry.Key == "GoogleID") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); GoogleId = (string)entry.Value; } // Ios Id else if (entry.Key == "IosID") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); IosId = (string)entry.Value; } // Rewards else if (entry.Key == "Rewards") { ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type."); Rewards = new PurchaseExchangeDefinition((IDictionary <string, object>)entry.Value); } } }
/// <summary> /// Initialises a new instance from the given Json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the Json data.</param> public Message(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("MessageID"), "Json is missing required field 'MessageID'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("From"), "Json is missing required field 'From'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("SentOn"), "Json is missing required field 'SentOn'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Read"), "Json is missing required field 'Read'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Message Id if (entry.Key == "MessageID") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); MessageId = (string)entry.Value; } // From else if (entry.Key == "From") { ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type."); From = new MessageSender((IDictionary <string, object>)entry.Value); } // Sent On else if (entry.Key == "SentOn") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); SentOn = JsonSerialisation.DeserialiseDate((string)entry.Value); } // Read else if (entry.Key == "Read") { ReleaseAssert.IsTrue(entry.Value is bool, "Invalid serialised type."); Read = (bool)entry.Value; } // Read On else if (entry.Key == "ReadOn") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); ReadOn = JsonSerialisation.DeserialiseDate((string)entry.Value); } } // Redeemed else if (entry.Key == "Redeemed") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is bool, "Invalid serialised type."); Redeemed = (bool)entry.Value; } } // Redeemed On else if (entry.Key == "RedeemedOn") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); RedeemedOn = JsonSerialisation.DeserialiseDate((string)entry.Value); } } // Tags else if (entry.Key == "Tags") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); Tags = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is string, "Invalid element type."); return((string)element); }); } } // Expiry else if (entry.Key == "Expiry") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); Expiry = (int)(long)entry.Value; } } // Title else if (entry.Key == "Title") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Title = (string)entry.Value; } } // Text else if (entry.Key == "Text") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Text = (string)entry.Value; } } // Data else if (entry.Key == "Data") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is object, "Invalid serialised type."); Data = new MultiTypeValue((object)entry.Value); } } // Rewards else if (entry.Key == "Rewards") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type."); Rewards = new MessageReward((IDictionary <string, object>)entry.Value); } } } }
/// <summary> /// Initialises a new instance from the given Json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the Json data.</param> public MatchTypeDefinition(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Key"), "Json is missing required field 'Key'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Name"), "Json is missing required field 'Name'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("TurnTypes"), "Json is missing required field 'TurnTypes'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("DefaultWaitingTimeout"), "Json is missing required field 'DefaultWaitingTimeout'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("DefaultTurnTimeout"), "Json is missing required field 'DefaultTurnTimeout'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Key if (entry.Key == "Key") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Key = (string)entry.Value; } // Name else if (entry.Key == "Name") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Name = (string)entry.Value; } // Turn Types else if (entry.Key == "TurnTypes") { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); TurnTypes = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is string, "Invalid element type."); return((string)element); }); } // Properties else if (entry.Key == "Properties") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); Properties = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is IDictionary <string, object>, "Invalid element type."); return(new MatchTypePropertyDefinition((IDictionary <string, object>)element)); }); } } // Default Waiting Timeout else if (entry.Key == "DefaultWaitingTimeout") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); DefaultWaitingTimeout = (int)(long)entry.Value; } // Default Turn Timeout else if (entry.Key == "DefaultTurnTimeout") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); DefaultTurnTimeout = (int)(long)entry.Value; } // Custom Data else if (entry.Key == "CustomData") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is object, "Invalid serialised type."); CustomData = new MultiTypeValue((object)entry.Value); } } } }
/// <summary> /// Initialises a new instance from the given Json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the Json data.</param> public MatchTurn(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("TurnNumber"), "Json is missing required field 'TurnNumber'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("State"), "Json is missing required field 'State'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("DateStarted"), "Json is missing required field 'DateStarted'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Turn Number if (entry.Key == "TurnNumber") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); TurnNumber = (int)(long)entry.Value; } // State else if (entry.Key == "State") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); State = (string)entry.Value; } // Players Waiting For else if (entry.Key == "PlayersWaitingFor") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); PlayersWaitingFor = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is IDictionary <string, object>, "Invalid element type."); return(new Player((IDictionary <string, object>)element)); }); } } // Player Turns else if (entry.Key == "PlayerTurns") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); PlayerTurns = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is IDictionary <string, object>, "Invalid element type."); return(new PlayerTurn((IDictionary <string, object>)element)); }); } } // Pre State Data else if (entry.Key == "PreStateData") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is object, "Invalid serialised type."); PreStateData = new MultiTypeValue((object)entry.Value); } } // Post State Data else if (entry.Key == "PostStateData") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is object, "Invalid serialised type."); PostStateData = new MultiTypeValue((object)entry.Value); } } // Date Started else if (entry.Key == "DateStarted") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); DateStarted = JsonSerialisation.DeserialiseDate((string)entry.Value); } // Date Completed else if (entry.Key == "DateCompleted") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); DateCompleted = JsonSerialisation.DeserialiseDate((string)entry.Value); } } } }
/// <summary> /// Initialises a new instance from the given Json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the Json data.</param> public MinimalMatch(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("MatchID"), "Json is missing required field 'MatchID'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("State"), "Json is missing required field 'State'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("TurnType"), "Json is missing required field 'TurnType'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("CanSubmitTurn"), "Json is missing required field 'CanSubmitTurn'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("DateCreated"), "Json is missing required field 'DateCreated'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Match Id if (entry.Key == "MatchID") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); MatchId = (string)entry.Value; } // State else if (entry.Key == "State") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); State = (string)entry.Value; } // Turn Type else if (entry.Key == "TurnType") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); TurnType = (string)entry.Value; } // Turn Number else if (entry.Key == "TurnNumber") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); TurnNumber = (int)(long)entry.Value; } } // Turn Timeout else if (entry.Key == "TurnTimeout") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type."); TurnTimeout = new Timeout((IDictionary <string, object>)entry.Value); } } // Waiting Timeout else if (entry.Key == "WaitingTimeout") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type."); WaitingTimeout = new Timeout((IDictionary <string, object>)entry.Value); } } // Players else if (entry.Key == "Players") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); Players = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is IDictionary <string, object>, "Invalid element type."); return(new Player((IDictionary <string, object>)element)); }); } } // Can Submit Turn else if (entry.Key == "CanSubmitTurn") { ReleaseAssert.IsTrue(entry.Value is bool, "Invalid serialised type."); CanSubmitTurn = (bool)entry.Value; } // Date Created else if (entry.Key == "DateCreated") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); DateCreated = JsonSerialisation.DeserialiseDate((string)entry.Value); } } }
/// <summary> /// Initialises a new instance from the given Json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the Json data.</param> public DlcPackage(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Type"), "Json is missing required field 'Type'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Name"), "Json is missing required field 'Name'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Checksum"), "Json is missing required field 'Checksum'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("DateUploaded"), "Json is missing required field 'DateUploaded'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Url"), "Json is missing required field 'Url'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Size"), "Json is missing required field 'Size'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Files"), "Json is missing required field 'Files'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Type if (entry.Key == "Type") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Type = (string)entry.Value; } // Name else if (entry.Key == "Name") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Name = (string)entry.Value; } // Checksum else if (entry.Key == "Checksum") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Checksum = (string)entry.Value; } // Date Uploaded else if (entry.Key == "DateUploaded") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); DateUploaded = JsonSerialisation.DeserialiseDate((string)entry.Value); } // Url else if (entry.Key == "Url") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Url = (string)entry.Value; } // Size else if (entry.Key == "Size") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); Size = (int)(long)entry.Value; } // Files else if (entry.Key == "Files") { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); Files = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is IDictionary <string, object>, "Invalid element type."); return(new DlcPackageFile((IDictionary <string, object>)element)); }); } } }
/// <summary> /// Initialises a new instance from the given Json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the Json data.</param> public Match(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("MatchID"), "Json is missing required field 'MatchID'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("MatchTypeKey"), "Json is missing required field 'MatchTypeKey'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("State"), "Json is missing required field 'State'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("WriteLock"), "Json is missing required field 'WriteLock'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("TurnType"), "Json is missing required field 'TurnType'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("AutoStart"), "Json is missing required field 'AutoStart'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("IsPrivate"), "Json is missing required field 'IsPrivate'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("DateCreated"), "Json is missing required field 'DateCreated'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Match Id if (entry.Key == "MatchID") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); MatchId = (string)entry.Value; } // Match Type Key else if (entry.Key == "MatchTypeKey") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); MatchTypeKey = (string)entry.Value; } // State else if (entry.Key == "State") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); State = (string)entry.Value; } // Write Lock else if (entry.Key == "WriteLock") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); WriteLock = (string)entry.Value; } // Properties else if (entry.Key == "Properties") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type."); Properties = JsonSerialisation.DeserialiseMap((IDictionary <string, object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is object, "Invalid element type."); return(new MultiTypeValue((object)element)); }); } } // State Data else if (entry.Key == "StateData") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is object, "Invalid serialised type."); StateData = new MultiTypeValue((object)entry.Value); } } // Outcome Data else if (entry.Key == "OutcomeData") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is object, "Invalid serialised type."); OutcomeData = new MultiTypeValue((object)entry.Value); } } // Turn Timeout else if (entry.Key == "TurnTimeout") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type."); TurnTimeout = new Timeout((IDictionary <string, object>)entry.Value); } } // Waiting Timeout else if (entry.Key == "WaitingTimeout") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type."); WaitingTimeout = new Timeout((IDictionary <string, object>)entry.Value); } } // Turn Type else if (entry.Key == "TurnType") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); TurnType = (string)entry.Value; } // Turn Order Type else if (entry.Key == "TurnOrderType") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); TurnOrderType = (string)entry.Value; } } // Player Limit else if (entry.Key == "PlayerLimit") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); PlayerLimit = (int)(long)entry.Value; } } // Players else if (entry.Key == "Players") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type."); Players = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is IDictionary <string, object>, "Invalid element type."); return(new Player((IDictionary <string, object>)element)); }); } } // Auto Start else if (entry.Key == "AutoStart") { ReleaseAssert.IsTrue(entry.Value is bool, "Invalid serialised type."); AutoStart = (bool)entry.Value; } // Is Private else if (entry.Key == "IsPrivate") { ReleaseAssert.IsTrue(entry.Value is bool, "Invalid serialised type."); IsPrivate = (bool)entry.Value; } // Turn Number else if (entry.Key == "TurnNumber") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); TurnNumber = (int)(long)entry.Value; } } // Last Turn else if (entry.Key == "LastTurn") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type."); LastTurn = new MatchTurn((IDictionary <string, object>)entry.Value); } } // Current Turn else if (entry.Key == "CurrentTurn") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type."); CurrentTurn = new MatchTurn((IDictionary <string, object>)entry.Value); } } // Created By else if (entry.Key == "CreatedBy") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type."); CreatedBy = new Player((IDictionary <string, object>)entry.Value); } } // Date Created else if (entry.Key == "DateCreated") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); DateCreated = JsonSerialisation.DeserialiseDate((string)entry.Value); } } }