Aracılığıyla paylaş


IBinarySerialize.Read(BinaryReader) Yöntem

Tanım

İkili biçiminden kullanıcı tanımlı tür (UDT) veya kullanıcı tanımlı toplama oluşturur.

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)

Parametreler

r
BinaryReader

Nesnenin seri durumda çıkarıldığı BinaryReader akışı.

Örnekler

Aşağıdaki örnekte, daha önce kalıcı hale getirilmiş bir UDT'nin seri durumdan BinaryReader çıkarıldığı bir UDT yönteminin uygulanması Read gösterilmektedir. Bu örnekte, UDT'nin iki veri özelliği olduğu varsayılır: StringValue ve DoubleValue.

// 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;
}

Açıklamalar

yöntemi tarafından Read yazılan bilgileri kullanarak nesnenizi yeniden oluşturması Write gerekir.

Şunlara uygulanır