다음을 통해 공유


BodyWriter.CreateBufferedCopy(Int32) 메서드

정의

본문의 버퍼링된 복사본을 만듭니다.

public:
 System::ServiceModel::Channels::BodyWriter ^ CreateBufferedCopy(int maxBufferSize);
public System.ServiceModel.Channels.BodyWriter CreateBufferedCopy (int maxBufferSize);
member this.CreateBufferedCopy : int -> System.ServiceModel.Channels.BodyWriter
Public Function CreateBufferedCopy (maxBufferSize As Integer) As BodyWriter

매개 변수

maxBufferSize
Int32

본문에 대한 최대 버퍼 크기입니다.

반환

이 개체의 복사본을 포함하는 BodyWriter입니다.

예외

maxBufferSize가 0보다 작은 경우

본문을 이미 써서 다시 쓸 수 없거나 본문 작성기가 버퍼링되지 않는 경우

예제

다음 예제에서는 기존 BodyWriter 인스턴스의 버퍼링된 복사본을 만드는 방법을 보여 줍니다.

string[] strings = { "Hello", "world" };
MyBodyWriter bodyWriter = new MyBodyWriter(strings);

StringBuilder strBuilder = new StringBuilder(10);
XmlWriter writer = XmlWriter.Create(strBuilder);
XmlDictionaryWriter dictionaryWriter = XmlDictionaryWriter.CreateDictionaryWriter(writer);

bodyWriter.WriteBodyContents(dictionaryWriter);
dictionaryWriter.Flush();

MyBodyWriter bufferedBodyWriter = (MyBodyWriter) bodyWriter.CreateBufferedCopy(1024);
Dim strings() As String = {"Hello", "world"}
Dim bodyWriter As New MyBodyWriter(strings)

Dim strBuilder As New StringBuilder(10)
Dim writer As XmlWriter = XmlWriter.Create(strBuilder)
Dim dictionaryWriter As XmlDictionaryWriter = XmlDictionaryWriter.CreateDictionaryWriter(writer)

bodyWriter.WriteBodyContents(dictionaryWriter)
dictionaryWriter.Flush()

Dim bufferedBodyWriter As MyBodyWriter = CType(bodyWriter.CreateBufferedCopy(1024), MyBodyWriter)

설명

IsBufferedtrue이면 BodyWriter 개체가 반환됩니다. IsBufferedfalse이면 BodyWriter의 콘텐츠가 최대 maxBufferSize까지 반환됩니다. 또한 OnCreateBufferedCopy(Int32)를 확장성 지점으로 호출합니다.

적용 대상