123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
-
- namespace UnityEngine.Purchasing
- {
- /// <summary>
- /// Definition of a purchase payout
- /// </summary>
- [Serializable]
- public class PayoutDefinition
- {
- [SerializeField]
- PayoutType m_Type = PayoutType.Other;
-
- [SerializeField]
- string m_Subtype = string.Empty;
-
- [SerializeField]
- double m_Quantity;
-
- [SerializeField]
- string m_Data = string.Empty;
-
- /// <summary>
- /// Type of the payout
- /// </summary>
- public PayoutType type
- {
- get => m_Type;
- private set => m_Type = value;
- }
-
-
- /// <summary>
- /// Type of the payout as a string
- /// </summary>
- public string typeString => m_Type.ToString();
-
-
- /// <summary>
- /// Maximum string length of the payout subtype
- /// </summary>
- public const int MaxSubtypeLength = 64;
-
- /// <summary>
- /// Subtype of the payout
- /// </summary>
- public string subtype
- {
- get => m_Subtype;
- private set
- {
- if (value.Length > MaxSubtypeLength)
- {
- throw new ArgumentException(string.Format("subtype cannot be longer than {0}", MaxSubtypeLength));
- }
-
- m_Subtype = value;
- }
- }
-
- /// <summary>
- /// Quantity or value of the payout
- /// </summary>
- public double quantity
- {
- get => m_Quantity;
- private set => m_Quantity = value;
- }
-
- /// <summary>
- /// Maximum number of bytes of the payout data
- /// </summary>
- public const int MaxDataLength = 1024;
-
- /// <summary>
- /// Payload data of the payout
- /// </summary>
- public string data
- {
- get => m_Data;
- private set
- {
- if (value.Length > MaxDataLength)
- {
- throw new ArgumentException(string.Format("data cannot be longer than {0}", MaxDataLength));
- }
-
- m_Data = value;
- }
- }
-
- /// <summary>
- /// Default constructor
- /// </summary>
- public PayoutDefinition()
- {
- }
-
- /// <summary>
- /// Parametrized constructor
- /// </summary>
- /// <param name="typeString"> The payout type, as a string. </param>
- /// <param name="subtype"> The payout subtype. </param>
- /// <param name="quantity"> The payout quantity. </param>
- public PayoutDefinition(string typeString, string subtype, double quantity) : this(typeString, subtype, quantity, string.Empty)
- {
- }
-
- /// <summary>
- /// Parametrized constructor
- /// </summary>
- /// <param name="typeString"> The payout type, as a string. </param>
- /// <param name="subtype"> The payout subtype. </param>
- /// <param name="quantity"> The payout quantity. </param>
- /// <param name="data"> The payout data. </param>
- public PayoutDefinition(string typeString, string subtype, double quantity, string data)
- {
- var t = PayoutType.Other;
- if (Enum.IsDefined(typeof(PayoutType), typeString))
- {
- t = (PayoutType)Enum.Parse(typeof(PayoutType), typeString);
- }
-
- type = t;
- this.subtype = subtype;
- this.quantity = quantity;
- this.data = data;
- }
-
- /// <summary>
- /// Parametrized constructor
- /// </summary>
- /// <param name="subtype"> The payout subtype. </param>
- /// <param name="quantity"> The payout quantity. </param>
- public PayoutDefinition(string subtype, double quantity) : this(PayoutType.Other, subtype, quantity, string.Empty)
- {
- }
-
- /// <summary>
- /// Parametrized constructor
- /// </summary>
- /// <param name="subtype"> The payout subtype. </param>
- /// <param name="quantity"> The payout quantity. </param>
- /// <param name="data"> The payout data. </param>
- public PayoutDefinition(string subtype, double quantity, string data) : this(PayoutType.Other, subtype, quantity, data)
- {
- }
-
- /// <summary>
- /// Parametrized constructor
- /// </summary>
- /// <param name="type"> The payout type. </param>
- /// <param name="subtype"> The payout subtype. </param>
- /// <param name="quantity"> The payout quantity. </param>
- public PayoutDefinition(PayoutType type, string subtype, double quantity) : this(type, subtype, quantity, string.Empty)
- {
- }
-
- /// <summary>
- /// Parametrized constructor
- /// </summary>
- /// <param name="type"> The payout type. </param>
- /// <param name="subtype"> The payout subtype. </param>
- /// <param name="quantity"> The payout quantity. </param>
- /// <param name="data"> The payout data. </param>
- public PayoutDefinition(PayoutType type, string subtype, double quantity, string data)
- {
- this.type = type;
- this.subtype = subtype;
- this.quantity = quantity;
- this.data = data;
- }
- }
- }
|