IBinarySerialize.Read(BinaryReader) 메서드

정의

해당 이진 형식에서 UDT(사용자 정의 형식) 또는 사용자 정의 집계를 생성합니다.

public:
 void Read(System::IO::BinaryReader ^ r);
public void Read (System.IO.BinaryReader r);
abstract member Read : System.IO.BinaryReader -> unit
Public Sub Read (r As BinaryReader)

매개 변수

r
BinaryReader

개체가 역직렬화되는 BinaryReader 스트림입니다.

예제

다음 예제에서는 을 사용하여 BinaryReader 이전에 지속된 UDT를 직렬화 해제하는 UDT 메서드의 구현 Read 을 보여 줍니다. 이 예제에서는 UDT에 및 DoubleValue의 두 가지 데이터 속성이 StringValue 있다고 가정합니다.

// The binary layout is as follows:
//    Bytes 0 - 19: string text, padded to the right with null characters
//    Bytes 20+: Double value

// using Microsoft.SqlServer.Server;
public void Read(System.IO.BinaryReader r)
{

    int maxStringSize = 20;
    char[] chars;
    int stringEnd;
    string stringValue;
    double doubleValue;

    // Read the characters from the binary stream.
    chars = r.ReadChars(maxStringSize);

    // Find the start of the null character padding.
    stringEnd = Array.IndexOf(chars, '\0');

    if (stringEnd == 0)
    {
        stringValue = null;
        return;
    }

    // Build the string from the array of characters.
    stringValue = new String(chars, 0, stringEnd);

    // Read the double value from the binary stream.
    doubleValue = r.ReadDouble();

    // Set the object's properties equal to the values.
    this.StringValue = stringValue;
    this.DoubleValue = doubleValue;
}

설명

메서드는 Read 메서드에서 작성한 Write 정보를 사용하여 개체를 재구성해야 합니다.

적용 대상