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