/// <summary> /// Initialises a new instance from the given Json dictionary. /// </summary> /// /// <param name="jsonDictionary">The dictionary containing the Json data.</param> public OneTimeVirtualPurchaseAvailabilityDefinition(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("Item"), "Json is missing required field 'Item'"); ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Available"), "Json is missing required field 'Available'"); 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; } // Item else if (entry.Key == "Item") { ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type."); Item = new VirtualPurchaseDefinition((IDictionary <string, object>)entry.Value); } // Available else if (entry.Key == "Available") { ReleaseAssert.IsTrue(entry.Value is bool, "Invalid serialised type."); Available = (bool)entry.Value; } } }
/// <summary> /// Initialises a new instance with the given properties. /// </summary> /// /// <param name="key">The key of the VirtualPurchase item.</param> /// <param name="item">The VirtualPurchase item.</param> /// <param name="available">Whether the attached VirtualPurchase item is available to be purchased.</param> public OneTimeVirtualPurchaseAvailabilityDefinition(string key, VirtualPurchaseDefinition item, bool available) { ReleaseAssert.IsNotNull(key, "Key cannot be null."); ReleaseAssert.IsNotNull(item, "Item cannot be null."); Key = key; Item = item; Available = available; }