BinaryClientFormatterSink.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. //
  2. // System.Runtime.Remoting.Channels.BinaryClientFormatterSink.cs
  3. //
  4. // Author: Rodrigo Moya ([email protected])
  5. // Dietmar Maurer ([email protected])
  6. //
  7. // 2002 (C) Copyright, Ximian, Inc.
  8. //
  9. using System.Collections;
  10. using System.IO;
  11. using System.Runtime.Remoting.Messaging;
  12. using System.Runtime.Serialization.Formatters.Binary;
  13. namespace System.Runtime.Remoting.Channels
  14. {
  15. public class BinaryClientFormatterSink : IClientFormatterSink,
  16. IMessageSink, IClientChannelSink, IChannelSinkBase
  17. {
  18. IClientChannelSink nextInChain;
  19. IRemotingFormatter formatter = new BinaryFormatter ();
  20. public BinaryClientFormatterSink (IClientChannelSink nextSink)
  21. {
  22. nextInChain = nextSink;
  23. }
  24. public IClientChannelSink NextChannelSink
  25. {
  26. get {
  27. return nextInChain;
  28. }
  29. }
  30. public IMessageSink NextSink
  31. {
  32. get {
  33. return (IMessageSink) nextInChain;
  34. }
  35. }
  36. public IDictionary Properties
  37. {
  38. get {
  39. return null;
  40. }
  41. }
  42. public IMessageCtrl AsyncProcessMessage (IMessage msg,
  43. IMessageSink replySink)
  44. {
  45. throw new NotImplementedException ();
  46. }
  47. public void AsyncProcessRequest (IClientChannelSinkStack sinkStack,
  48. IMessage msg,
  49. ITransportHeaders headers,
  50. Stream stream)
  51. {
  52. // never called because the formatter sink is
  53. // always the first in the chain
  54. throw new NotSupportedException ();
  55. }
  56. [MonoTODO]
  57. public void AsyncProcessResponse (IClientResponseChannelSinkStack sinkStack,
  58. object state,
  59. ITransportHeaders headers,
  60. Stream stream)
  61. {
  62. throw new NotImplementedException ();
  63. }
  64. public Stream GetRequestStream (IMessage msg,
  65. ITransportHeaders headers)
  66. {
  67. // never called
  68. throw new NotSupportedException ();
  69. }
  70. public void ProcessMessage (IMessage msg,
  71. ITransportHeaders requestHeaders,
  72. Stream requestStream,
  73. out ITransportHeaders responseHeaders,
  74. out Stream responseStream)
  75. {
  76. // never called because the formatter sink is
  77. // always the first in the chain
  78. throw new NotSupportedException ();
  79. }
  80. [MonoTODO]
  81. public IMessage SyncProcessMessage (IMessage msg)
  82. {
  83. try {
  84. ITransportHeaders response_headers;
  85. Stream response_stream;
  86. // fixme: use nextInChain.GetRequestStream() ??
  87. Stream out_stream = new MemoryStream ();
  88. //Stream out_stream = File.Open ("test.bin", FileMode.Create);
  89. // serialize msg to the stream
  90. //formatter.Serialize (out_stream, msg, null);
  91. //formatter.Serialize (out_stream, new Exception ("TEST"), null);
  92. //out_stream.Position = 0;
  93. nextInChain.ProcessMessage (msg, null, out_stream, out response_headers,
  94. out response_stream);
  95. out_stream.Close ();
  96. // deserialize response_stream
  97. //IMessage result = (IMessage) formatter.Deserialize (response_stream, null);
  98. throw new NotImplementedException ();
  99. return null;
  100. } catch (Exception e) {
  101. return new ReturnMessage (e, (IMethodCallMessage)msg);
  102. }
  103. }
  104. }
  105. }