共用方式為


MessageBuffer Class

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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

Inheritance Hierarchy

System.Object
  System.ServiceModel.Channels.MessageBuffer

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

Syntax

'Declaration
Public MustInherit Class MessageBuffer _
    Implements IDisposable
public abstract class MessageBuffer : IDisposable

The MessageBuffer type exposes the following members.

Constructors

  Name Description
Protected methodSupported by Silverlight for Windows Phone MessageBuffer Initializes a new instance of the MessageBuffer class.

Top

Properties

  Name Description
Public propertySupported by Silverlight for Windows Phone BufferSize Gets the approximate number of bytes accessed by this MessageBuffer.
Public propertySupported by Silverlight for Windows Phone MessageContentType Gets the type of message content stored in this buffer.

Top

Methods

  Name Description
Public methodSupported by Silverlight for Windows Phone Close Finishes working with the buffer.
Public methodSupported by Silverlight for Windows Phone CreateMessage Returns a copy of the original message.
Public methodSupported by Silverlight for Windows Phone Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows Phone Finalize Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone GetType Gets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows Phone MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone ToString Returns a string that represents the current object. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone WriteMessage Writes the entire content of this buffer to the specified I/O stream.

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate methodSupported by Silverlight for Windows Phone IDisposable.Dispose Releases the unmanaged resources used by the MessageBuffer and optionally releases the managed resources. This method cannot be inherited.

Top

Remarks

The body of a Message instance can only be accessed or written once. If you wish to access 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.

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 ensures the underlying Message (the message passed into the constructor) instance is also closed, which frees system resources.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Thread Safety

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