Returns a serializer that can read/write a DbGuid to and from a stream.
Syntax
Example
Library/Library.Test/TestDbGuid.cs
C# | Copy Code |
---|
DbGuid[] ids = new DbGuid[16];
MemoryStream stream = new MemoryStream();
for (int i = 0; i < ids.Length; i++)
{
ids[i] = DbGuid.NewGuid();
DbGuid.Serializer.WriteTo(ids[i], stream);
}
stream.Position = 0;
for (int i = 0; i < ids.Length; i++)
{
DbGuid test = DbGuid.Serializer.ReadFrom(stream);
Assert.AreEqual(ids[i], test);
}
Assert.AreEqual(-1, stream.ReadByte()); |
VB.NET | Copy Code |
---|
Dim ids As DbGuid() = New DbGuid(16) {}
Dim stream As New MemoryStream()
Dim i As Integer = 0
While i < ids.Length
ids(i) = DbGuid.NewGuid()
DbGuid.Serializer.WriteTo(ids(i), stream)
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
stream.Position = 0
Dim i As Integer = 0
While i < ids.Length
Dim test As DbGuid = DbGuid.Serializer.ReadFrom(stream)
Assert.AreEqual(ids(i), test)
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
Assert.AreEqual(-1, stream.ReadByte()) |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also