CSharpTest.Net
Serializer Field
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Data Namespace > DbGuid Structure : Serializer Field

Glossary Item Box

Returns a serializer that can read/write a DbGuid to and from a stream.

Syntax

Visual Basic (Declaration) 
Public Shared ReadOnly Serializer As ISerializer(Of DbGuid)
C# 
public static readonly ISerializer<DbGuid> Serializer

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.NETCopy 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

Generated with Document! X 2011 by Innovasys