コード例 #1
0
        /// <summary>
        /// Initialises a new instance with the given required properties.
        /// </summary>
        ///
        /// <param name="key">The key of the item.</param>
        /// <param name="name">The name of the item.</param>
        /// <param name="tags">The tags of the item.</param>
        /// <param name="costs">Costs that are required to make a purchase.</param>
        /// <param name="rewards">Rewards that will be allocated upon purchase.</param>
        public VirtualPurchaseDefinitionDesc(string key, string name, IList <string> tags, PurchaseExchangeDefinition costs, PurchaseExchangeDefinition rewards)
        {
            ReleaseAssert.IsNotNull(key, "Key cannot be null.");
            ReleaseAssert.IsNotNull(name, "Name cannot be null.");
            ReleaseAssert.IsNotNull(tags, "Tags cannot be null.");
            ReleaseAssert.IsNotNull(costs, "Costs cannot be null.");
            ReleaseAssert.IsNotNull(rewards, "Rewards cannot be null.");

            Key     = key;
            Name    = name;
            Tags    = Mutability.ToImmutable(tags);
            Costs   = costs;
            Rewards = rewards;
        }
コード例 #2
0
        /// <summary>
        /// Initialises a new instance with the given description.
        /// </summary>
        ///
        /// <param name="desc">The description.</param>
        public VirtualPurchaseDefinition(VirtualPurchaseDefinitionDesc desc)
        {
            ReleaseAssert.IsNotNull(desc, "A description object cannot be null.");

            ReleaseAssert.IsNotNull(desc.Key, "Key cannot be null.");
            ReleaseAssert.IsNotNull(desc.Name, "Name cannot be null.");
            ReleaseAssert.IsNotNull(desc.Tags, "Tags cannot be null.");
            ReleaseAssert.IsNotNull(desc.Costs, "Costs cannot be null.");
            ReleaseAssert.IsNotNull(desc.Rewards, "Rewards cannot be null.");

            Key        = desc.Key;
            Name       = desc.Name;
            Tags       = Mutability.ToImmutable(desc.Tags);
            CustomData = desc.CustomData;
            Costs      = desc.Costs;
            Rewards    = desc.Rewards;
        }
コード例 #3
0
        /// <summary>
        /// Initialises a new instance with the given required properties.
        /// </summary>
        ///
        /// <param name="key">The key of the item.</param>
        /// <param name="name">The name of the item.</param>
        /// <param name="tags">The tags of the item.</param>
        /// <param name="amazonId">The Amazon Product SKU.</param>
        /// <param name="googleId">The Google Play Product ID.</param>
        /// <param name="iosId">The iOS App Store Identifier.</param>
        /// <param name="rewards">Rewards that will be allocated upon purchase.</param>
        public RealMoneyPurchaseDefinitionDesc(string key, string name, IList <string> tags, string amazonId, string googleId, string iosId, PurchaseExchangeDefinition rewards)
        {
            ReleaseAssert.IsNotNull(key, "Key cannot be null.");
            ReleaseAssert.IsNotNull(name, "Name cannot be null.");
            ReleaseAssert.IsNotNull(tags, "Tags cannot be null.");
            ReleaseAssert.IsNotNull(amazonId, "Amazon Id cannot be null.");
            ReleaseAssert.IsNotNull(googleId, "Google Id cannot be null.");
            ReleaseAssert.IsNotNull(iosId, "Ios Id cannot be null.");
            ReleaseAssert.IsNotNull(rewards, "Rewards cannot be null.");

            Key      = key;
            Name     = name;
            Tags     = Mutability.ToImmutable(tags);
            AmazonId = amazonId;
            GoogleId = googleId;
            IosId    = iosId;
            Rewards  = rewards;
        }
コード例 #4
0
        /// <summary>
        /// Initialises a new instance with the given description.
        /// </summary>
        ///
        /// <param name="desc">The description.</param>
        public RealMoneyPurchaseDefinition(RealMoneyPurchaseDefinitionDesc desc)
        {
            ReleaseAssert.IsNotNull(desc, "A description object cannot be null.");

            ReleaseAssert.IsNotNull(desc.Key, "Key cannot be null.");
            ReleaseAssert.IsNotNull(desc.Name, "Name cannot be null.");
            ReleaseAssert.IsNotNull(desc.Tags, "Tags cannot be null.");
            ReleaseAssert.IsNotNull(desc.AmazonId, "AmazonId cannot be null.");
            ReleaseAssert.IsNotNull(desc.GoogleId, "GoogleId cannot be null.");
            ReleaseAssert.IsNotNull(desc.IosId, "IosId cannot be null.");
            ReleaseAssert.IsNotNull(desc.Rewards, "Rewards cannot be null.");

            Key        = desc.Key;
            Name       = desc.Name;
            Tags       = Mutability.ToImmutable(desc.Tags);
            CustomData = desc.CustomData;
            AmazonId   = desc.AmazonId;
            GoogleId   = desc.GoogleId;
            IosId      = desc.IosId;
            Rewards    = desc.Rewards;
        }
コード例 #5
0
        /// <summary>
        /// Initialises a new instance from the given Json dictionary.
        /// </summary>
        ///
        /// <param name="jsonDictionary">The dictionary containing the Json data.</param>
        public VirtualPurchaseDefinition(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("Costs"), "Json is missing required field 'Costs'");
            ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Rewards"), "Json is missing required field 'Rewards'");

            foreach (KeyValuePair <string, object> entry in jsonDictionary)
            {
                // Key
                if (entry.Key == "Key")
                {
                    ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type.");
                    Key = (string)entry.Value;
                }

                // Name
                else if (entry.Key == "Name")
                {
                    ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type.");
                    Name = (string)entry.Value;
                }

                // Tags
                else if (entry.Key == "Tags")
                {
                    ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type.");
                    Tags = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) =>
                    {
                        ReleaseAssert.IsTrue(element is string, "Invalid element type.");
                        return((string)element);
                    });
                }

                // Custom Data
                else if (entry.Key == "CustomData")
                {
                    if (entry.Value != null)
                    {
                        ReleaseAssert.IsTrue(entry.Value is object, "Invalid serialised type.");
                        CustomData = new MultiTypeValue((object)entry.Value);
                    }
                }

                // Costs
                else if (entry.Key == "Costs")
                {
                    ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type.");
                    Costs = new PurchaseExchangeDefinition((IDictionary <string, object>)entry.Value);
                }

                // Rewards
                else if (entry.Key == "Rewards")
                {
                    ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type.");
                    Rewards = new PurchaseExchangeDefinition((IDictionary <string, object>)entry.Value);
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// Initialises a new instance from the given Json dictionary.
        /// </summary>
        ///
        /// <param name="jsonDictionary">The dictionary containing the Json data.</param>
        public RealMoneyPurchaseDefinition(IDictionary <string, object> jsonDictionary)
        {
            ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null.");
            ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Key"), "Json is missing required field 'Key'");
            ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Name"), "Json is missing required field 'Name'");
            ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Tags"), "Json is missing required field 'Tags'");
            ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("AmazonID"), "Json is missing required field 'AmazonID'");
            ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("GoogleID"), "Json is missing required field 'GoogleID'");
            ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("IosID"), "Json is missing required field 'IosID'");
            ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Rewards"), "Json is missing required field 'Rewards'");

            foreach (KeyValuePair <string, object> entry in jsonDictionary)
            {
                // Key
                if (entry.Key == "Key")
                {
                    ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type.");
                    Key = (string)entry.Value;
                }

                // Name
                else if (entry.Key == "Name")
                {
                    ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type.");
                    Name = (string)entry.Value;
                }

                // Tags
                else if (entry.Key == "Tags")
                {
                    ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type.");
                    Tags = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) =>
                    {
                        ReleaseAssert.IsTrue(element is string, "Invalid element type.");
                        return((string)element);
                    });
                }

                // Custom Data
                else if (entry.Key == "CustomData")
                {
                    if (entry.Value != null)
                    {
                        ReleaseAssert.IsTrue(entry.Value is object, "Invalid serialised type.");
                        CustomData = new MultiTypeValue((object)entry.Value);
                    }
                }

                // Amazon Id
                else if (entry.Key == "AmazonID")
                {
                    ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type.");
                    AmazonId = (string)entry.Value;
                }

                // Google Id
                else if (entry.Key == "GoogleID")
                {
                    ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type.");
                    GoogleId = (string)entry.Value;
                }

                // Ios Id
                else if (entry.Key == "IosID")
                {
                    ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type.");
                    IosId = (string)entry.Value;
                }

                // Rewards
                else if (entry.Key == "Rewards")
                {
                    ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type.");
                    Rewards = new PurchaseExchangeDefinition((IDictionary <string, object>)entry.Value);
                }

                // An error has occurred.
                else
                {
#if DEBUG
                    throw new ArgumentException("Input Json contains an invalid field.");
#endif
                }
            }
        }