PrimitiveTester.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.ServiceModel;
  5. namespace MonoTests.Features.Contracts
  6. {
  7. // Define a service contract.
  8. [ServiceContract (Namespace = "http://MonoTests.Features.Contracts")]
  9. public interface IPrimitiveTesterContract
  10. {
  11. [OperationContract]
  12. void DoNothing ();
  13. [OperationContract]
  14. int AddByte (byte n1, byte n2);
  15. [OperationContract]
  16. int AddSByte (sbyte n1, sbyte n2);
  17. [OperationContract]
  18. int AddShort (short n1, short n2);
  19. [OperationContract]
  20. int AddUShort (ushort n1, ushort n2);
  21. [OperationContract]
  22. int AddInt (int n1, int n2);
  23. [OperationContract]
  24. uint AddUInt (uint n1, uint n2);
  25. [OperationContract]
  26. long AddLong (long n1, long n2);
  27. [OperationContract]
  28. ulong AddULong (ulong n1, ulong n2);
  29. [OperationContract]
  30. double AddDouble (double n1, double n2);
  31. [OperationContract]
  32. float AddFloat (float n1, float n2);
  33. [OperationContract]
  34. char AddChar (char n1, char c2);
  35. [OperationContract]
  36. void AddByRef(double n1, double n2, out double n3, out double n4);
  37. [OperationContract]
  38. int? NullableInt (int? x);
  39. [OperationContract]
  40. float? NullableFloat (float? x);
  41. [OperationContract]
  42. TimeSpan AddTimeSpan (TimeSpan t1, TimeSpan t2);
  43. [OperationContract]
  44. byte [] AddByteArray (byte [] b1, byte [] b2);
  45. }
  46. public class PrimitiveTester : IPrimitiveTesterContract
  47. {
  48. public void DoNothing () {
  49. }
  50. public int AddByte (byte n1, byte n2) {
  51. return (byte) n1 + n2;
  52. }
  53. public int AddSByte (sbyte n1, sbyte n2) {
  54. return n1 + n2;
  55. }
  56. public int AddShort (short n1, short n2) {
  57. return n1 + n2;
  58. }
  59. public int AddUShort (ushort n1, ushort n2) {
  60. return n1 + n2;
  61. }
  62. public int AddInt (int n1, int n2) {
  63. return n1 + n2;
  64. }
  65. public uint AddUInt (uint n1, uint n2) {
  66. return n1 + n2;
  67. }
  68. public long AddLong (long n1, long n2) {
  69. return n1 + n2;
  70. }
  71. public ulong AddULong (ulong n1, ulong n2) {
  72. return n1 + n2;
  73. }
  74. public double AddDouble (double n1, double n2) {
  75. return n1 + n2;
  76. }
  77. public float AddFloat (float n1, float n2) {
  78. return n1 + n2;
  79. }
  80. public char AddChar (char n1, char n2) {
  81. return (char)(n1 + n2);
  82. }
  83. public void AddByRef (double n1, double n2, out double n3, out double n4) {
  84. n3 = n4 = n1 + n2;
  85. }
  86. public int? NullableInt(int?x) {
  87. return x==null ? x : x+1;
  88. }
  89. public float? NullableFloat (float? x) {
  90. return x == null ? x : x + 1;
  91. }
  92. public TimeSpan AddTimeSpan (TimeSpan t1, TimeSpan t2) {
  93. return t1.Add (t2);
  94. }
  95. public byte [] AddByteArray (byte [] b1, byte [] b2) {
  96. byte [] ret = new byte [b1.Length];
  97. for (int i = 0; i < b1.Length; i++)
  98. ret [i] = (byte) (b1 [i] + b2 [i]);
  99. return ret;
  100. }
  101. }
  102. }