/// <summary> /// Initialises a new instance from the given Json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the Json data.</param> public ResetPeriods(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Start"), "Json is missing required field 'Start'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Start if (entry.Key == "Start") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Start = JsonSerialisation.DeserialiseDate((string)entry.Value); } // End else if (entry.Key == "End") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); End = 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 PlayerTurn(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("DateSubmitted"), "Json is missing required field 'DateSubmitted'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Turn Data if (entry.Key == "TurnData") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is object, "Invalid serialised type."); TurnData = new MultiTypeValue((object)entry.Value); } } // Player else if (entry.Key == "Player") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type."); Player = new Player((IDictionary <string, object>)entry.Value); } } // Date Submitted else if (entry.Key == "DateSubmitted") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); DateSubmitted = 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 AssignedTest(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("StartDate"), "Json is missing required field 'StartDate'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("TestGroup"), "Json is missing required field 'TestGroup'"); 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; } // Start Date else if (entry.Key == "StartDate") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); StartDate = JsonSerialisation.DeserialiseDate((string)entry.Value); } // End Date else if (entry.Key == "EndDate") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); EndDate = JsonSerialisation.DeserialiseDate((string)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); } } // Test Group else if (entry.Key == "TestGroup") { ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type."); TestGroup = new TestGroupDetails((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 PlayerData(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("Value"), "Json is missing required field 'Value'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("DateCreated"), "Json is missing required field 'DateCreated'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("DateModified"), "Json is missing required field 'DateModified'"); 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; } // Value else if (entry.Key == "Value") { ReleaseAssert.IsTrue(entry.Value is object, "Invalid serialised type."); Value = new MultiTypeValue((object)entry.Value); } // Write Lock else if (entry.Key == "WriteLock") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); WriteLock = (string)entry.Value; } } // Date Created else if (entry.Key == "DateCreated") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); DateCreated = JsonSerialisation.DeserialiseDate((string)entry.Value); } // Date Modified else if (entry.Key == "DateModified") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); DateModified = JsonSerialisation.DeserialiseDate((string)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 GetPlayerScoreResponse(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Score"), "Json is missing required field 'Score'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("GlobalRank"), "Json is missing required field 'GlobalRank'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("GlobalTotal"), "Json is missing required field 'GlobalTotal'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Date"), "Json is missing required field 'Date'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Data if (entry.Key == "Data") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is object, "Invalid serialised type."); Data = new MultiTypeValue((object)entry.Value); } } // Score else if (entry.Key == "Score") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); Score = (int)(long)entry.Value; } // Global Rank else if (entry.Key == "GlobalRank") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); GlobalRank = (int)(long)entry.Value; } // Global Total else if (entry.Key == "GlobalTotal") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); GlobalTotal = (int)(long)entry.Value; } // Date else if (entry.Key == "Date") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Date = JsonSerialisation.DeserialiseDate((string)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 MetricsEvent(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("Date"), "Json is missing required field 'Date'"); 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; } // Date else if (entry.Key == "Date") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Date = JsonSerialisation.DeserialiseDate((string)entry.Value); } // Parameters else if (entry.Key == "Params") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type."); Parameters = JsonSerialisation.DeserialiseMap((IDictionary <string, object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is string, "Invalid element type."); return((string)element); }); } } // Count else if (entry.Key == "Count") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); Count = (int)(long)entry.Value; } } } }
/// <summary> /// Initialises a new instance from the given Json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the Json data.</param> public Timeout(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("SecondsRemaining"), "Json is missing required field 'SecondsRemaining'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Expires"), "Json is missing required field 'Expires'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Seconds Remaining if (entry.Key == "SecondsRemaining") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); SecondsRemaining = (int)(long)entry.Value; } // Expires else if (entry.Key == "Expires") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Expires = 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 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 CollectionDataObject(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("ObjectID"), "Json is missing required field 'ObjectID'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("CreatedBy"), "Json is missing required field 'CreatedBy'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("DateCreated"), "Json is missing required field 'DateCreated'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Value"), "Json is missing required field 'Value'"); foreach (KeyValuePair <string, object> entry in jsonDictionary) { // Object Id if (entry.Key == "ObjectID") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); ObjectId = (string)entry.Value; } // Created By else if (entry.Key == "CreatedBy") { 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); } // Modified By else if (entry.Key == "ModifiedBy") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type."); ModifiedBy = new Player((IDictionary <string, object>)entry.Value); } } // Date Modified else if (entry.Key == "DateModified") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); DateModified = JsonSerialisation.DeserialiseDate((string)entry.Value); } } // Value else if (entry.Key == "Value") { ReleaseAssert.IsTrue(entry.Value is object, "Invalid serialised type."); Value = new MultiTypeValue((object)entry.Value); } // Write Lock else if (entry.Key == "WriteLock") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); WriteLock = (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); } } // 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 MetricsEvent(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("Date"), "Json is missing required field 'Date'"); 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; } // Date else if (entry.Key == "Date") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Date = JsonSerialisation.DeserialiseDate((string)entry.Value); } // User Grade else if (entry.Key == "UserGrade") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); UserGrade = (int)(long)entry.Value; } } // Test Group else if (entry.Key == "TestGroup") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); TestGroup = (string)entry.Value; } } // Parameters else if (entry.Key == "Params") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type."); Parameters = JsonSerialisation.DeserialiseMap((IDictionary <string, object>)entry.Value, (object element) => { ReleaseAssert.IsTrue(element is string, "Invalid element type."); return((string)element); }); } } // Count else if (entry.Key == "Count") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); Count = (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 FacebookPlayerData(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("ChilliConnectID"), "Json is missing required field 'ChilliConnectID'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Key"), "Json is missing required field 'Key'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Value"), "Json is missing required field 'Value'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("FacebookName"), "Json is missing required field 'FacebookName'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("DateCreated"), "Json is missing required field 'DateCreated'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("DateModified"), "Json is missing required field 'DateModified'"); 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; } // Key else if (entry.Key == "Key") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Key = (string)entry.Value; } // Value else if (entry.Key == "Value") { ReleaseAssert.IsTrue(entry.Value is object, "Invalid serialised type."); Value = new MultiTypeValue((object)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; } } // Facebook Name else if (entry.Key == "FacebookName") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); FacebookName = (string)entry.Value; } // Date Created else if (entry.Key == "DateCreated") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); DateCreated = JsonSerialisation.DeserialiseDate((string)entry.Value); } // Date Modified else if (entry.Key == "DateModified") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); DateModified = 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 PlayerData(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("DateCreated"), "Json is missing required field 'DateCreated'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("DateModified"), "Json is missing required field 'DateModified'"); 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; } // Value else if (entry.Key == "Value") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is object, "Invalid serialised type."); Value = new MultiTypeValue((object)entry.Value); } } // Has Attachment else if (entry.Key == "HasAttachment") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is bool, "Invalid serialised type."); HasAttachment = (bool)entry.Value; } } // Write Lock else if (entry.Key == "WriteLock") { if (entry.Value != null) { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); WriteLock = (string)entry.Value; } } // Date Created else if (entry.Key == "DateCreated") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); DateCreated = JsonSerialisation.DeserialiseDate((string)entry.Value); } // Date Modified else if (entry.Key == "DateModified") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); DateModified = JsonSerialisation.DeserialiseDate((string)entry.Value); } } }
/// <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'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("DateCreated"), "Json is missing required field 'DateCreated'"); 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; } } // 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 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 GlobalScore(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("ChilliConnectID"), "Json is missing required field 'ChilliConnectID'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Date"), "Json is missing required field 'Date'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Score"), "Json is missing required field 'Score'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("GlobalRank"), "Json is missing required field 'GlobalRank'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("GlobalTotal"), "Json is missing required field 'GlobalTotal'"); 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; } } // Date else if (entry.Key == "Date") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Date = JsonSerialisation.DeserialiseDate((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); } } // Score else if (entry.Key == "Score") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); Score = (int)(long)entry.Value; } // Global Rank else if (entry.Key == "GlobalRank") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); GlobalRank = (int)(long)entry.Value; } // Global Total else if (entry.Key == "GlobalTotal") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); GlobalTotal = (int)(long)entry.Value; } } }
/// <summary> /// Initialises a new instance from the given Json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the Json data.</param> public FacebookScore(IDictionary <string, object> jsonDictionary) { ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null."); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("ChilliConnectID"), "Json is missing required field 'ChilliConnectID'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("FacebookName"), "Json is missing required field 'FacebookName'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("FacebookProfileImage"), "Json is missing required field 'FacebookProfileImage'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Date"), "Json is missing required field 'Date'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Score"), "Json is missing required field 'Score'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("GlobalRank"), "Json is missing required field 'GlobalRank'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("GlobalTotal"), "Json is missing required field 'GlobalTotal'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("LocalRank"), "Json is missing required field 'LocalRank'"); 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; } } // Facebook Name else if (entry.Key == "FacebookName") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); FacebookName = (string)entry.Value; } // Facebook Profile Image else if (entry.Key == "FacebookProfileImage") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); FacebookProfileImage = (string)entry.Value; } // Date else if (entry.Key == "Date") { ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type."); Date = JsonSerialisation.DeserialiseDate((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); } } // Score else if (entry.Key == "Score") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); Score = (int)(long)entry.Value; } // Global Rank else if (entry.Key == "GlobalRank") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); GlobalRank = (int)(long)entry.Value; } // Global Total else if (entry.Key == "GlobalTotal") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); GlobalTotal = (int)(long)entry.Value; } // Local Rank else if (entry.Key == "LocalRank") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); LocalRank = (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 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); } } }