ArrayConverterTestClass.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. namespace Jint.Tests.Runtime.Domain
  5. {
  6. public class ArrayConverterTestClass
  7. {
  8. public string MethodAcceptsArrayOfStrings(string[] arrayOfStrings)
  9. {
  10. return SerializeToString(arrayOfStrings);
  11. }
  12. public string MethodAcceptsArrayOfInt(int[] arrayOfInt)
  13. {
  14. return SerializeToString(arrayOfInt);
  15. }
  16. public string MethodAcceptsArrayOfBool(int[] arrayOfBool)
  17. {
  18. return SerializeToString(arrayOfBool);
  19. }
  20. private static string SerializeToString<T>(IEnumerable<T> array)
  21. {
  22. return String.Join(",", array);
  23. }
  24. }
  25. public class ArrayConverterItem : IConvertible
  26. {
  27. private readonly int _value;
  28. public ArrayConverterItem(int value)
  29. {
  30. _value = value;
  31. }
  32. public override string ToString()
  33. {
  34. return ToString(CultureInfo.InvariantCulture);
  35. }
  36. public string ToString(IFormatProvider provider)
  37. {
  38. return _value.ToString(provider);
  39. }
  40. public int ToInt32(IFormatProvider provider)
  41. {
  42. return Convert.ToInt32(_value, provider);
  43. }
  44. #region NotImplemented
  45. public TypeCode GetTypeCode()
  46. {
  47. throw new NotImplementedException();
  48. }
  49. public bool ToBoolean(IFormatProvider provider)
  50. {
  51. throw new NotImplementedException();
  52. }
  53. public char ToChar(IFormatProvider provider)
  54. {
  55. throw new NotImplementedException();
  56. }
  57. public sbyte ToSByte(IFormatProvider provider)
  58. {
  59. throw new NotImplementedException();
  60. }
  61. public byte ToByte(IFormatProvider provider)
  62. {
  63. throw new NotImplementedException();
  64. }
  65. public short ToInt16(IFormatProvider provider)
  66. {
  67. throw new NotImplementedException();
  68. }
  69. public ushort ToUInt16(IFormatProvider provider)
  70. {
  71. throw new NotImplementedException();
  72. }
  73. public uint ToUInt32(IFormatProvider provider)
  74. {
  75. throw new NotImplementedException();
  76. }
  77. public long ToInt64(IFormatProvider provider)
  78. {
  79. throw new NotImplementedException();
  80. }
  81. public ulong ToUInt64(IFormatProvider provider)
  82. {
  83. throw new NotImplementedException();
  84. }
  85. public float ToSingle(IFormatProvider provider)
  86. {
  87. throw new NotImplementedException();
  88. }
  89. public double ToDouble(IFormatProvider provider)
  90. {
  91. throw new NotImplementedException();
  92. }
  93. public decimal ToDecimal(IFormatProvider provider)
  94. {
  95. throw new NotImplementedException();
  96. }
  97. public DateTime ToDateTime(IFormatProvider provider)
  98. {
  99. throw new NotImplementedException();
  100. }
  101. public object ToType(Type conversionType, IFormatProvider provider)
  102. {
  103. throw new NotImplementedException();
  104. }
  105. #endregion
  106. }
  107. }