AnySDKParam.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using UnityEngine;
  2. using System.Collections.Generic;
  3. using System.Collections;
  4. using System;
  5. using System.Text;
  6. using System.Runtime.InteropServices;
  7. namespace anysdk {
  8. [StructLayoutAttribute(LayoutKind.Sequential)]
  9. public struct AnySDKParam {
  10. private ParamType _type;
  11. private int _intValue;
  12. private float _floatValue;
  13. private bool _boolValue;
  14. private string _strValue;
  15. private string _strMapValue;
  16. enum ParamType {
  17. kParamTypeNull=0,
  18. kParamTypeInt,
  19. kParamTypeFloat,
  20. kParamTypeBool,
  21. kParamTypeString,
  22. kParamTypeStringMap,
  23. kParamTypeMap
  24. };
  25. public AnySDKParam(int nValue) {
  26. _intValue = nValue;
  27. _floatValue = 0;
  28. _boolValue = false;
  29. _strValue = null;
  30. _strMapValue = null;
  31. _type = ParamType.kParamTypeInt;
  32. }
  33. public AnySDKParam(float nValue) {
  34. _intValue = 0;
  35. _floatValue = nValue;
  36. _boolValue = false;
  37. _strValue = null;
  38. _strMapValue = null;
  39. _type = ParamType.kParamTypeFloat;
  40. }
  41. public AnySDKParam(bool nValue) {
  42. _intValue = 0;
  43. _floatValue = 0;
  44. _boolValue = nValue;
  45. _strValue = null;
  46. _strMapValue = null;
  47. _type = ParamType.kParamTypeBool;
  48. }
  49. public AnySDKParam(string nValue) {
  50. _intValue = 0;
  51. _floatValue = 0;
  52. _boolValue = false;
  53. _strValue = nValue;
  54. _strMapValue = null;
  55. _type = ParamType.kParamTypeString;
  56. }
  57. public AnySDKParam(Dictionary<string,string> nValue) {
  58. _intValue = 0;
  59. _floatValue = 0;
  60. _boolValue = false;
  61. _strValue = null;
  62. _strMapValue = AnySDKUtil.dictionaryToString( nValue);
  63. _type = ParamType.kParamTypeStringMap;
  64. }
  65. public int getCurrentType() {
  66. return (int)_type;
  67. }
  68. public int getIntValue() {
  69. return _intValue;
  70. }
  71. public float getFloatValue() {
  72. return _floatValue;
  73. }
  74. public bool getBoolValue() {
  75. return _boolValue;
  76. }
  77. public string getStringValue() {
  78. return _strValue;
  79. }
  80. public string getStrMapValue() {
  81. return _strMapValue;
  82. }
  83. }
  84. }