CSharpTest.Net
Int32 Field
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Serialization Namespace > PrimitiveSerializer Class : Int32 Field

Glossary Item Box

Gets a typed version of the PrimitiveSerializer

Syntax

Visual Basic (Declaration) 
Public Shared ReadOnly Int32 As ISerializer(Of Integer)
C# 
public static readonly ISerializer<int> Int32

Example

Library/Library.Test/TestSegmentedStream.cs

C#Copy Code
using (SharedMemoryStream shared = new SharedMemoryStream())
{
    shared.Position = ushort.MaxValue - 25;
    Assert.AreEqual(ushort.MaxValue - 25, shared.Length);
    Assert.AreEqual(ushort.MaxValue - 25, shared.Position);

    using (Stream copy = ((IFactory<Stream>) shared).Create())
    {
        Assert.AreEqual(0L, copy.Position);//does not clone position of original stream...
        Assert.AreEqual(shared.Length, copy.Length);//does clone length of the stream...
        copy.Position = shared.Position;

        for (int i = 0; i < 100; i++)
        {
            PrimitiveSerializer.Int32.WriteTo(i, shared);
            Assert.AreEqual(i, PrimitiveSerializer.Int32.ReadFrom(copy));
        }
    }
}
VB.NETCopy Code
Using [shared] As New SharedMemoryStream()
    [shared].Position = UShort.MaxValue - 25
    Assert.AreEqual(UShort.MaxValue - 25, [shared].Length)
    Assert.AreEqual(UShort.MaxValue - 25, [shared].Position)

    Using copy As Stream = (DirectCast([shared], IFactory(Of Stream))).Create()
        Assert.AreEqual(0L, copy.Position)
        'does not clone position of original stream...
        Assert.AreEqual([shared].Length, copy.Length)
        'does clone length of the stream...
        copy.Position = [shared].Position

        Dim i As Integer = 0
        While i < 100
            PrimitiveSerializer.Int32.WriteTo(i, [shared])
            Assert.AreEqual(i, PrimitiveSerializer.Int32.ReadFrom(copy))
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While
    End Using
End Using

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Reference

PrimitiveSerializer Class
PrimitiveSerializer Members

Used By

TransactionLog.CommitTransaction(TransactionToken)
TestBPlusTreeOptions.TestICloneable()
TestBPlusTreeOptions.TestReadOnly()
TestBPlusTreeOptions.TestCloneWithCallLockV1()
TestBPlusTreeOptions.TestCloneWithCallLockV2()
BasicFileTests.TestRecoverCorruptedFile()
TestMultiInstance.TestSyncFromLogging()
TestTransactionLog.TestTransactionLogOptions()

Source Code

Library/Serialization/PrimitiveSerializer.cs

Generated with Document! X 2011 by Innovasys