IFragmentCapableXmlDictionaryWriter.WriteFragment(Byte[], Int32, Int32) 메서드

정의

XML 조각을 작성기의 기본 스트림에 씁니다.Writes an XML fragment to the underlying stream of the writer.

public:
 void WriteFragment(cli::array <System::Byte> ^ buffer, int offset, int count);
public void WriteFragment (byte[] buffer, int offset, int count);
abstract member WriteFragment : byte[] * int * int -> unit
Public Sub WriteFragment (buffer As Byte(), offset As Integer, count As Integer)

매개 변수

buffer
Byte[]

쓸 버퍼입니다.The buffer to write to.

offset
Int32

buffer에서 쓸 시작 위치입니다.The starting position from which to write in buffer.

count
Int32

buffer에 쓸 바이트 수 입니다.The number of bytes to be written to the buffer.

예제

MemoryStream stream = new MemoryStream();  
MemoryStream fragmentStream = new MemoryStream();  
XmlDictionaryWriter writer = XmlDictionaryWriter.CreateTextWriter(stream);  
IXmlFragmentCapableXmlDictionaryWriter fragmentWriter = writer as IXmlFragmentCapableXmlDictionaryWriter;  
if (fragmentWriter == null || !fragmentWriter.CanFragment)  
{  
Console.WriteLine("This writer doesn't support fragments");  
return;  
}  
writer.WriteStartElement("Root");  
fragmentWriter.StartFragment(fragmentStream, false);  
writer.WriteStartElement("Body");  
writer.WriteString("This is my body");  
writer.WriteEndElement();  
fragmentWriter.EndFragment();  
writer.WriteStartElement("CharsInTheBody");  
writer.WriteValue(fragmentStream.Length);  
writer.WriteEndElement();  
fragmentWriter.WriteFragment(fragmentStream.GetBuffer(), 0, (int)fragmentStream.Length);  
writer.WriteEndElement(); // Root  

설명

StartFragmentEndFragment 사이에서 캡처된 조각을 쓰고 XmlDictionaryWriter의 주 스트림으로 다시 호출 합니다.Writes a fragment captured between StartFragment and EndFragment and calls back into the XmlDictionaryWriter's main stream. 작성 된 조각은 제공 된 buffer의 인덱스 offset부터 시작 하 여 바이트를 count 합니다.The fragment written is count bytes starting at the index offset from the supplied buffer. 제공된 조각이 이 작성자 인스턴스를 사용하여 캡처되지 않은 경우 동작이 정의되지 않습니다.The behavior is undefined if the supplied fragment was not captured using this writer instance.

적용 대상