static void Main(string[] args) { string serviceUrl = string.Format("https://companycheck.p.mashape.com/companySearch?name={0}", "Google"); var result = getDataFromAPI(serviceUrl).Body; var serializer = new JsonSerialisation<List<CompanySearchResult>>(); var searchResults = serializer.FromString(result); Console.WriteLine(searchResults); }
/// <summary> /// Serialises all properties. The output will be a dictionary containing the /// objects properties in a form that can easily be converted to Json. /// </summary> /// /// <returns>The serialised object in dictionary form.</returns> public IDictionary <string, object> Serialise() { var dictionary = new Dictionary <string, object>(); // Object Id dictionary.Add("ObjectID", ObjectId); // Created By if (CreatedBy != null) { dictionary.Add("CreatedBy", CreatedBy.Serialise()); } // Date Created dictionary.Add("DateCreated", JsonSerialisation.Serialise(DateCreated)); // Modified By if (ModifiedBy != null) { dictionary.Add("ModifiedBy", ModifiedBy.Serialise()); } // Date Modified if (DateModified != null) { dictionary.Add("DateModified", JsonSerialisation.Serialise(DateModified)); } // Value dictionary.Add("Value", Value.Serialise()); // Write Lock if (WriteLock != null) { dictionary.Add("WriteLock", WriteLock); } return(dictionary); }
/// <summary> /// Serialises all properties. The output will be a dictionary containing the /// objects properties in a form that can easily be converted to Json. /// </summary> /// /// <returns>The serialised object in dictionary form.</returns> public IDictionary <string, object> Serialise() { var dictionary = new Dictionary <string, object>(); // Chilli Connect Id dictionary.Add("ChilliConnectID", ChilliConnectId); // User Name if (UserName != null) { dictionary.Add("UserName", UserName); } // Display Name if (DisplayName != null) { dictionary.Add("DisplayName", DisplayName); } // Date dictionary.Add("Date", JsonSerialisation.Serialise(Date)); // Data if (Data != null) { dictionary.Add("Data", Data.Serialise()); } // Score dictionary.Add("Score", Score); // Global Rank dictionary.Add("GlobalRank", GlobalRank); // Global Total dictionary.Add("GlobalTotal", GlobalTotal); return(dictionary); }
/// <summary> /// Initialises a new instance from the given Json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the Json data.</param> public PurchaseExchangeDefinition(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 PurchaseCurrencyExchangeDefinition((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 PurchaseInventoryExchangeDefinition((IDictionary <string, object>)element)); }); } // An error has occurred. else { #if DEBUG throw new ArgumentException("Input Json contains an invalid field."); #endif } } }
/// <summary> /// Serialises all properties. The output will be a dictionary containing the /// objects properties in a form that can easily be converted to Json. /// </summary> /// /// <returns>The serialised object in dictionary form.</returns> public IDictionary <string, object> Serialise() { var dictionary = new Dictionary <string, object>(); // Currencies var serialisedCurrencies = JsonSerialisation.Serialise(Currencies, (PurchaseCurrencyExchangeDefinition element) => { return(element.Serialise()); }); dictionary.Add("Currencies", serialisedCurrencies); // Items var serialisedItems = JsonSerialisation.Serialise(Items, (PurchaseInventoryExchangeDefinition element) => { return(element.Serialise()); }); dictionary.Add("Items", serialisedItems); return(dictionary); }
/// <summary> /// Serialises all properties. The output will be a dictionary containing the /// objects properties in a form that can easily be converted to Json. /// </summary> /// /// <returns>The serialised object in dictionary form.</returns> public IDictionary <string, object> Serialise() { var dictionary = new Dictionary <string, object>(); // Currencies var serialisedCurrencies = JsonSerialisation.Serialise(Currencies, (MessageRewardCurrency element) => { return(element.Serialise()); }); dictionary.Add("Currencies", serialisedCurrencies); // Items var serialisedItems = JsonSerialisation.Serialise(Items, (MessageRewardInventory element) => { return(element.Serialise()); }); dictionary.Add("Items", serialisedItems); return(dictionary); }
/// <summary> /// Serialises all body properties. The output will be a dictionary containing the /// body of the request in a form that can easily be converted to Json. Will return /// an empty dictionary if there is no body. /// </summary> /// /// <returns>The body Json in dictionary form.</returns> public IDictionary <string, object> SerialiseBody() { var dictionary = new Dictionary <string, object>(); // Chilli Connect Id dictionary.Add("ChilliConnectID", ChilliConnectId); // Chilli Connect Secret dictionary.Add("ChilliConnectSecret", ChilliConnectSecret); // Device Model if (DeviceModel != null) { dictionary.Add("DeviceModel", DeviceModel); } // Device Type if (DeviceType != null) { dictionary.Add("DeviceType", DeviceType); } // Platform if (Platform != null) { dictionary.Add("Platform", Platform); } // Date dictionary.Add("Date", JsonSerialisation.Serialise(Date)); // App Version if (AppVersion != null) { dictionary.Add("AppVersion", AppVersion); } return(dictionary); }
/// <summary> /// Serialises all properties. The output will be a dictionary containing the /// objects properties in a form that can easily be converted to Json. /// </summary> /// /// <returns>The serialised object in dictionary form.</returns> public IDictionary <string, object> Serialise() { var dictionary = new Dictionary <string, object>(); // Key dictionary.Add("Key", Key); // Name dictionary.Add("Name", Name); // Tags var serialisedTags = JsonSerialisation.Serialise(Tags, (string element) => { return(element); }); dictionary.Add("Tags", serialisedTags); // Custom Data if (CustomData != null) { dictionary.Add("CustomData", CustomData.Serialise()); } // Amazon Id dictionary.Add("AmazonID", AmazonId); // Google Id dictionary.Add("GoogleID", GoogleId); // Ios Id dictionary.Add("IosID", IosId); // Rewards dictionary.Add("Rewards", Rewards.Serialise()); return(dictionary); }
/// <summary> /// Serialises all body properties. The output will be a dictionary containing the /// body of the request in a form that can easily be converted to Json. Will return /// an empty dictionary if there is no body. /// </summary> /// /// <returns>The body Json in dictionary form.</returns> public IDictionary <string, object> SerialiseBody() { var dictionary = new Dictionary <string, object>(); // Key dictionary.Add("Key", Key); // Chilli Connect Ids var serialisedChilliConnectIds = JsonSerialisation.Serialise(ChilliConnectIds, (string element) => { return(element); }); dictionary.Add("ChilliConnectIDs", serialisedChilliConnectIds); // Include Me if (IncludeMe != null) { dictionary.Add("IncludeMe", IncludeMe); } return(dictionary); }
/// <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> /// Serialises all properties. The output will be a dictionary containing the /// objects properties in a form that can easily be converted to Json. /// </summary> /// /// <returns>The serialised object in dictionary form.</returns> public IDictionary <string, object> Serialise() { var dictionary = new Dictionary <string, object>(); // Url dictionary.Add("Url", Url); // Checksum dictionary.Add("Checksum", Checksum); // Size dictionary.Add("Size", Size); // Files var serialisedFiles = JsonSerialisation.Serialise(Files, (ZipPackageDefinitionPackageFile element) => { return(element.Serialise()); }); dictionary.Add("Files", serialisedFiles); return(dictionary); }
/// <summary> /// Serialises all properties. The output will be a dictionary containing the /// objects properties in a form that can easily be converted to Json. /// </summary> /// /// <returns>The serialised object in dictionary form.</returns> public IDictionary <string, object> Serialise() { var dictionary = new Dictionary <string, object>(); // Name dictionary.Add("Name", Name); // Key dictionary.Add("Key", Key); // Amount dictionary.Add("Amount", Amount); // Item Ids var serialisedItemIds = JsonSerialisation.Serialise(ItemIds, (string element) => { return(element); }); dictionary.Add("ItemIDs", serialisedItemIds); return(dictionary); }
/// <summary> /// Serialises all properties. The output will be a dictionary containing the /// objects properties in a form that can easily be converted to Json. /// </summary> /// /// <returns>The serialised object in dictionary form.</returns> public IDictionary <string, object> Serialise() { var dictionary = new Dictionary <string, object>(); // Key dictionary.Add("Key", Key); // Value dictionary.Add("Value", Value.Serialise()); // Write Lock if (WriteLock != null) { dictionary.Add("WriteLock", WriteLock); } // Date Created dictionary.Add("DateCreated", JsonSerialisation.Serialise(DateCreated)); // Date Modified dictionary.Add("DateModified", JsonSerialisation.Serialise(DateModified)); return(dictionary); }
/// <summary> /// Serialises all properties. The output will be a dictionary containing the /// objects properties in a form that can easily be converted to Json. /// </summary> /// /// <returns>The serialised object in dictionary form.</returns> public IDictionary <string, object> Serialise() { var dictionary = new Dictionary <string, object>(); // Chilli Connect Id dictionary.Add("ChilliConnectID", ChilliConnectId); // Key dictionary.Add("Key", Key); // Value dictionary.Add("Value", Value.Serialise()); // User Name if (UserName != null) { dictionary.Add("UserName", UserName); } // Display Name if (DisplayName != null) { dictionary.Add("DisplayName", DisplayName); } // Facebook Name dictionary.Add("FacebookName", FacebookName); // Date Created dictionary.Add("DateCreated", JsonSerialisation.Serialise(DateCreated)); // Date Modified dictionary.Add("DateModified", JsonSerialisation.Serialise(DateModified)); return(dictionary); }
/// <summary> /// Serialises all body properties. The output will be a dictionary containing the /// body of the request in a form that can easily be converted to Json. Will return /// an empty dictionary if there is no body. /// </summary> /// /// <returns>The body Json in dictionary form.</returns> public IDictionary <string, object> SerialiseBody() { var dictionary = new Dictionary <string, object>(); // Facebook Access Token dictionary.Add("FacebookAccessToken", FacebookAccessToken); // Device Model if (DeviceModel != null) { dictionary.Add("DeviceModel", DeviceModel); } // Device Type if (DeviceType != null) { dictionary.Add("DeviceType", DeviceType); } // Platform if (Platform != null) { dictionary.Add("Platform", Platform); } // Date dictionary.Add("Date", JsonSerialisation.Serialise(Date)); // App Version if (AppVersion != null) { dictionary.Add("AppVersion", AppVersion); } return(dictionary); }
/// <summary> /// Serialises all body properties. The output will be a dictionary containing the /// body of the request in a form that can easily be converted to Json. Will return /// an empty dictionary if there is no body. /// </summary> /// /// <returns>The body Json in dictionary form.</returns> public IDictionary <string, object> SerialiseBody() { var dictionary = new Dictionary <string, object>(); // Date dictionary.Add("Date", JsonSerialisation.Serialise(Date)); // User Grade if (UserGrade != null) { dictionary.Add("UserGrade", UserGrade); } // Test Group if (TestGroup != null) { dictionary.Add("TestGroup", TestGroup); } // Offer if (Offer != null) { dictionary.Add("Offer", Offer); } // Item dictionary.Add("Item", Item); // Local Cost dictionary.Add("LocalCost", LocalCost); // Local Currency dictionary.Add("LocalCurrency", LocalCurrency); return(dictionary); }
/// <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> /// Serialises all properties. The output will be a dictionary containing the /// objects properties in a form that can easily be converted to Json. /// </summary> /// /// <returns>The serialised object in dictionary form.</returns> public IDictionary <string, object> Serialise() { var dictionary = new Dictionary <string, object>(); // Message Id dictionary.Add("MessageID", MessageId); // From dictionary.Add("From", From.Serialise()); // Sent On dictionary.Add("SentOn", JsonSerialisation.Serialise(SentOn)); // Read dictionary.Add("Read", Read); // Read On if (ReadOn.HasValue) { dictionary.Add("ReadOn", JsonSerialisation.Serialise(ReadOn.Value)); } // Redeemed if (Redeemed != null) { dictionary.Add("Redeemed", Redeemed); } // Redeemed On if (RedeemedOn.HasValue) { dictionary.Add("RedeemedOn", JsonSerialisation.Serialise(RedeemedOn.Value)); } // Tags if (Tags != null) { var serialisedTags = JsonSerialisation.Serialise(Tags, (string element) => { return(element); }); dictionary.Add("Tags", serialisedTags); } // Expiry if (Expiry != null) { dictionary.Add("Expiry", Expiry); } // Title if (Title != null) { dictionary.Add("Title", Title); } // Text if (Text != null) { dictionary.Add("Text", Text); } // Data if (Data != null) { dictionary.Add("Data", Data.Serialise()); } // Rewards if (Rewards != null) { dictionary.Add("Rewards", Rewards.Serialise()); } return(dictionary); }
/// <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> /// Serialises all properties. The output will be a dictionary containing the /// objects properties in a form that can easily be converted to Json. /// </summary> /// /// <returns>The serialised object in dictionary form.</returns> public IDictionary <string, object> Serialise() { var dictionary = new Dictionary <string, object>(); // Match Id dictionary.Add("MatchID", MatchId); // Match Type Key dictionary.Add("MatchTypeKey", MatchTypeKey); // State dictionary.Add("State", State); // Write Lock dictionary.Add("WriteLock", WriteLock); // Properties if (Properties != null) { var serialisedProperties = JsonSerialisation.Serialise(Properties, (MultiTypeValue element) => { return(element.Serialise()); }); dictionary.Add("Properties", serialisedProperties); } // State Data if (StateData != null) { dictionary.Add("StateData", StateData.Serialise()); } // Outcome Data if (OutcomeData != null) { dictionary.Add("OutcomeData", OutcomeData.Serialise()); } // Turn Timeout if (TurnTimeout != null) { dictionary.Add("TurnTimeout", TurnTimeout.Serialise()); } // Waiting Timeout if (WaitingTimeout != null) { dictionary.Add("WaitingTimeout", WaitingTimeout.Serialise()); } // Turn Type dictionary.Add("TurnType", TurnType); // Turn Order Type if (TurnOrderType != null) { dictionary.Add("TurnOrderType", TurnOrderType); } // Player Limit if (PlayerLimit != null) { dictionary.Add("PlayerLimit", PlayerLimit); } // Players if (Players != null) { var serialisedPlayers = JsonSerialisation.Serialise(Players, (Player element) => { return(element.Serialise()); }); dictionary.Add("Players", serialisedPlayers); } // Auto Start dictionary.Add("AutoStart", AutoStart); // Is Private dictionary.Add("IsPrivate", IsPrivate); // Turn Number if (TurnNumber != null) { dictionary.Add("TurnNumber", TurnNumber); } // Last Turn if (LastTurn != null) { dictionary.Add("LastTurn", LastTurn.Serialise()); } // Current Turn if (CurrentTurn != null) { dictionary.Add("CurrentTurn", CurrentTurn.Serialise()); } // Created By if (CreatedBy != null) { dictionary.Add("CreatedBy", CreatedBy.Serialise()); } // Date Created dictionary.Add("DateCreated", JsonSerialisation.Serialise(DateCreated)); return(dictionary); }
/// <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 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 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 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; } } } }
/// <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 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 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 CurrencyDefinition(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("Initial"), "Json is missing required field 'Initial'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Max"), "Json is missing required field 'Max'"); 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); } } // Initial else if (entry.Key == "Initial") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); Initial = (int)(long)entry.Value; } // Max else if (entry.Key == "Max") { ReleaseAssert.IsTrue(entry.Value is long, "Invalid serialised type."); Max = (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 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); } } }