IWebMessageEncoderHelper.cs 2.5 KB

12345678910111213141516171819202122232425262728293031
  1. // <copyright>
  2. // Copyright (c) Microsoft Corporation. All rights reserved.
  3. // </copyright>
  4. namespace System.ServiceModel.Channels
  5. {
  6. // In .net 4.0, the WebMessageEncoder uses a raw encoder, different than ByteStreamMessageEncoder. This raw encoder produces Messages for which the
  7. // Message.GetReaderAtBodyContents() method returns an XmlDictionaryReader positioned on content (the root element of the xml); that's because MoveToContent()
  8. // is called on the reader before it's returned.
  9. //
  10. // Starting with .net 4.5, the WebMessageEncoder uses the ByteStreamMessageEncoder. By default, this encoder produces Messages for which the body reader is initially
  11. // positioned on None (just before the root element). It does so for compatibility with .net 4.0. So we need the WebMessageEncoder to create a non-default
  12. // ByteStreamMessageEncoder that triggers the MoveToContent() call. We don't want to expose a direct public way to create this non-default ByteStreamMessageEncoder
  13. // and WebMessageEncoder (from System.ServiceModel.Web.dll) doesn't have access to the internals of ByteStreamMessageEncoder (from System.ServiceModel.Channels.dll).
  14. // So we use this intermediate interface.
  15. //
  16. // This is what we want to have:
  17. // +---------------------+------------------------------------------------------------+--------------------------------------------------------------------------+
  18. // | | WebMessageEncodingBindingElement/WebMessageEncoder is used | ByteStreamMessageEncodingBindingElement/ByteStreamMessageEncoder is used |
  19. // +=====================+============================================================+==========================================================================+
  20. // | .net 4.0 | the Message body reader is initially positioned on content | the Message body reader is initially positioned on None |
  21. // +---------------------+------------------------------------------------------------+--------------------------------------------------------------------------+
  22. // | .net 4.5 (or after) | the Message body reader is initially positioned on content | the Message body reader is initially positioned on None |
  23. // +---------------------+------------------------------------------------------------+--------------------------------------------------------------------------+
  24. //
  25. // See 252277 @ CSDMain for other info.
  26. internal interface IWebMessageEncoderHelper
  27. {
  28. void EnableBodyReaderMoveToContent();
  29. }
  30. }