DelegateCalls.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. //
  2. // MonoTests.Remoting.DelegateCalls.cs
  3. //
  4. // Author: Lluis Sanchez Gual ([email protected])
  5. //
  6. // 2003 (C) Copyright, Ximian, Inc.
  7. //
  8. using System;
  9. using System.Collections;
  10. using NUnit.Framework;
  11. using System.Text;
  12. using System.Runtime.InteropServices;
  13. namespace MonoTests.Remoting
  14. {
  15. public abstract class DelegateCallTest : BaseCallTest
  16. {
  17. public override InstanceSurrogate GetInstanceSurrogate () { return new DelegateInstanceSurrogate (); }
  18. public override AbstractSurrogate GetAbstractSurrogate () { return new DelegateAbstractSurrogate (); }
  19. public override InterfaceSurrogate GetInterfaceSurrogate () { return new DelegateInterfaceSurrogate (); }
  20. }
  21. public class DelegateInstanceSurrogate : InstanceSurrogate
  22. {
  23. public override int Simple ()
  24. {
  25. DelegateSimple de = new DelegateSimple (RemoteObject.Simple);
  26. return de ();
  27. }
  28. public override string PrimitiveParams (int a, uint b, char c, string d)
  29. {
  30. DelegatePrimitiveParams de = new DelegatePrimitiveParams (RemoteObject.PrimitiveParams);
  31. return de (a,b,c,d);
  32. }
  33. public override string PrimitiveParamsInOut (ref int a1, out int a2, ref float b1, out float b2, int filler, ref char c1, out char c2, ref string d1, out string d2)
  34. {
  35. DelegatePrimitiveParamsInOut de = new DelegatePrimitiveParamsInOut (RemoteObject.PrimitiveParamsInOut);
  36. return de (ref a1, out a2, ref b1, out b2, filler, ref c1, out c2, ref d1, out d2);
  37. }
  38. public override Complex ComplexParams (ArrayList a, Complex b, string c)
  39. {
  40. DelegateComplexParams de = new DelegateComplexParams (RemoteObject.ComplexParams);
  41. return de (a,b,c);
  42. }
  43. public override Complex ComplexParamsInOut (ref ArrayList a, out Complex b, [In,Out] byte[] bytes, [In,Out] StringBuilder sb, string c)
  44. {
  45. DelegateComplexParamsInOut de = new DelegateComplexParamsInOut (RemoteObject.ComplexParamsInOut);
  46. return de (ref a, out b, bytes, sb, c);
  47. }
  48. public override void ProcessContextData ()
  49. {
  50. DelegateProcessContextData de = new DelegateProcessContextData (RemoteObject.ProcessContextData);
  51. de ();
  52. }
  53. }
  54. public class DelegateAbstractSurrogate : AbstractSurrogate
  55. {
  56. public override int Simple ()
  57. {
  58. DelegateSimple de = new DelegateSimple (RemoteObject.Simple);
  59. return de ();
  60. }
  61. public override string PrimitiveParams (int a, uint b, char c, string d)
  62. {
  63. DelegatePrimitiveParams de = new DelegatePrimitiveParams (RemoteObject.PrimitiveParams);
  64. return de (a,b,c,d);
  65. }
  66. public override string PrimitiveParamsInOut (ref int a1, out int a2, ref float b1, out float b2, int filler, ref char c1, out char c2, ref string d1, out string d2)
  67. {
  68. DelegatePrimitiveParamsInOut de = new DelegatePrimitiveParamsInOut (RemoteObject.PrimitiveParamsInOut);
  69. return de (ref a1, out a2, ref b1, out b2, filler, ref c1, out c2, ref d1, out d2);
  70. }
  71. public override Complex ComplexParams (ArrayList a, Complex b, string c)
  72. {
  73. DelegateComplexParams de = new DelegateComplexParams (RemoteObject.ComplexParams);
  74. return de (a,b,c);
  75. }
  76. public override Complex ComplexParamsInOut (ref ArrayList a, out Complex b, [In,Out] byte[] bytes, [In,Out] StringBuilder sb, string c)
  77. {
  78. DelegateComplexParamsInOut de = new DelegateComplexParamsInOut (RemoteObject.ComplexParamsInOut);
  79. return de (ref a, out b, bytes, sb, c);
  80. }
  81. public override void ProcessContextData ()
  82. {
  83. DelegateProcessContextData de = new DelegateProcessContextData (RemoteObject.ProcessContextData);
  84. de ();
  85. }
  86. }
  87. public class DelegateInterfaceSurrogate : InterfaceSurrogate
  88. {
  89. public override int Simple ()
  90. {
  91. DelegateSimple de = new DelegateSimple (RemoteObject.Simple);
  92. return de ();
  93. }
  94. public override string PrimitiveParams (int a, uint b, char c, string d)
  95. {
  96. DelegatePrimitiveParams de = new DelegatePrimitiveParams (RemoteObject.PrimitiveParams);
  97. return de (a,b,c,d);
  98. }
  99. public override string PrimitiveParamsInOut (ref int a1, out int a2, ref float b1, out float b2, int filler, ref char c1, out char c2, ref string d1, out string d2)
  100. {
  101. DelegatePrimitiveParamsInOut de = new DelegatePrimitiveParamsInOut (RemoteObject.PrimitiveParamsInOut);
  102. return de (ref a1, out a2, ref b1, out b2, filler, ref c1, out c2, ref d1, out d2);
  103. }
  104. public override Complex ComplexParams (ArrayList a, Complex b, string c)
  105. {
  106. DelegateComplexParams de = new DelegateComplexParams (RemoteObject.ComplexParams);
  107. return de (a,b,c);
  108. }
  109. public override Complex ComplexParamsInOut (ref ArrayList a, out Complex b, [In,Out] byte[] bytes, [In,Out] StringBuilder sb, string c)
  110. {
  111. DelegateComplexParamsInOut de = new DelegateComplexParamsInOut (RemoteObject.ComplexParamsInOut);
  112. return de (ref a, out b, bytes, sb, c);
  113. }
  114. public override void ProcessContextData ()
  115. {
  116. DelegateProcessContextData de = new DelegateProcessContextData (RemoteObject.ProcessContextData);
  117. de ();
  118. }
  119. }
  120. }