説明なし
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

XMLUtils.cs 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Xml;
  7. using System.Xml.Linq;
  8. namespace UnityEngine.Purchasing.Default
  9. {
  10. /// <summary>
  11. /// A utility class to parse Universal Windows Platform products from XML data.
  12. /// </summary>
  13. public class XMLUtils
  14. {
  15. /// <summary>
  16. /// A utility class to parse Universal Windows Platform products from XML data.
  17. /// </summary>
  18. /// <param name="appReceipt"> The app receipt as raw XML data. </param>
  19. /// <returns> The <c>TransactionInfo</c> for the products parsed from the XML data. </returns>
  20. public static IEnumerable<TransactionInfo> ParseProducts(string appReceipt)
  21. {
  22. if (null == appReceipt)
  23. {
  24. return new List<TransactionInfo>();
  25. }
  26. try
  27. {
  28. var xml = XElement.Parse(appReceipt);
  29. return from product in xml.Descendants("ProductReceipt")
  30. select new TransactionInfo()
  31. {
  32. productId = (string)product.Attribute("ProductId"),
  33. transactionId = (string)product.Attribute("Id")
  34. };
  35. }
  36. catch (XmlException)
  37. {
  38. return new List<TransactionInfo>();
  39. }
  40. }
  41. /// <summary>
  42. /// Data of a transaction for Universal Windows Platform product purchases.
  43. /// </summary>
  44. public class TransactionInfo
  45. {
  46. /// <summary>
  47. /// The ID of the product.
  48. /// </summary>
  49. public string productId;
  50. /// <summary>
  51. /// The transaction ID for the purchase.
  52. /// </summary>
  53. public string transactionId;
  54. }
  55. }
  56. }