IronSourceSegment.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.Linq;
  5. public class IronSourceSegment
  6. {
  7. public int age;
  8. public string gender = null;
  9. public int level;
  10. public int isPaying;
  11. public long userCreationDate;
  12. public double iapt;
  13. public string segmentName = null;
  14. public Dictionary<string,string> customs;
  15. public IronSourceSegment ()
  16. {
  17. customs = new Dictionary<string,string> ();
  18. age = -1;
  19. level = -1;
  20. isPaying = -1;
  21. userCreationDate = -1;
  22. iapt = 0;
  23. }
  24. public void setCustom(string key, string value){
  25. customs.Add (key, value);
  26. }
  27. public Dictionary<string,string> getSegmentAsDict ()
  28. {
  29. Dictionary<string,string> temp = new Dictionary<string,string> ();
  30. if (age != -1)
  31. temp.Add ("age", age + "");
  32. if (!string.IsNullOrEmpty(gender))
  33. temp.Add ("gender", gender);
  34. if (level != -1)
  35. temp.Add ("level", level + "");
  36. if (isPaying > -1 && isPaying < 2)
  37. temp.Add ("isPaying", isPaying + "");
  38. if (userCreationDate != -1)
  39. temp.Add ("userCreationDate", userCreationDate + "");
  40. if (!string.IsNullOrEmpty(segmentName))
  41. temp.Add ("segmentName", segmentName);
  42. if (iapt > 0)
  43. temp.Add ("iapt", iapt + "");
  44. Dictionary<string,string> result = temp.Concat (customs).GroupBy (d => d.Key).ToDictionary (d => d.Key, d => d.First ().Value);
  45. return result;
  46. }
  47. }