Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

MessageBuffer Class

 

Represents a memory buffer that stores an entire message for future consumption.

Namespace:   System.ServiceModel.Channels
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

System.Object
  System.ServiceModel.Channels.MessageBuffer

public abstract class MessageBuffer : IXPathNavigable, IDisposable

NameDescription
System_CAPS_protmethodMessageBuffer()

Initializes a new instance of the MessageBuffer class.

NameDescription
System_CAPS_pubpropertyBufferSize

Gets the approximate number of bytes consumed by this MessageBuffer.

System_CAPS_pubpropertyMessageContentType

Gets the type of message content stored in this buffer.

NameDescription
System_CAPS_pubmethodClose()

Finishes working with the buffer.

System_CAPS_pubmethodCreateMessage()

Returns a copy of the original message.

System_CAPS_pubmethodCreateNavigator()

Creates a new XPathNavigator object for navigating this object. This method cannot be inherited.

System_CAPS_pubmethodCreateNavigator(Int32)

Creates a new XPathNavigator object for navigating this object, with the navigator positioned on the node specified.

System_CAPS_pubmethodCreateNavigator(Int32, XmlSpace)

Creates a new XPathNavigator object for navigating this object, with the navigator positioned on the specified node and xml:space scope.

System_CAPS_pubmethodCreateNavigator(XmlSpace)

Creates a new XPathNavigator object for navigating this object, with the specified xml:space scope.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

System_CAPS_pubmethodWriteMessage(Stream)

Writes the entire content of this buffer to the specified IO stream.

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodIDisposable.Dispose()

Releases the unmanaged resources used by the MessageBuffer and optionally releases the managed resources. This method cannot be inherited.

The body of a Message instance can only be consumed or written once. If you wish to consume a Message instance more than once, you should use the MessageBuffer class to completely store an entire Message instance into memory.

A MessageBuffer instance is constructed by calling CreateBufferedCopy of a Message instance. A new MessageBuffer is then created and returned, which assumes ownership of the Message and reads the entire content into memory.

In order to retrieve a copy of a Message from the MessageBuffer, you must call the CreateMessage method of the MessageBuffer. This returns an identical copy of the original Message instance you provided.

You can control the maximum size of the buffer by setting BufferSize to the maximum number of bytes desired. This number does not necessarily cover any transient allocations related to building the buffer, or properties attached to the message.

You should always close a MessageBuffer instance by calling Close when finished working with it. This allows system resources to potentially be freed sooner.

Special note for Managed C++ users deriving from this class:

  • Put your cleanup code in (On)(Begin)Close (and/or OnAbort), not in a destructor.

  • Avoid destructors: they cause the compiler to auto-generate IDisposable

  • Avoid non-reference members: they can cause the compiler to auto-generate IDisposable

  • Avoid finalizers; but if you include one, you should suppress the build warning and call SuppressFinalize(Object) and the finalizer itself from (On)(Begin)Close (and/or OnAbort) in order to emulate what would have been the auto-generated IDisposable behavior.

Universal Windows Platform
Available since 8
.NET Framework
Available since 3.0
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft