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

Glossary Item Box

Gets a typed version of the PrimitiveSerializer

Syntax

Visual Basic (Declaration) 
Public Shared ReadOnly Int64 As ISerializer(Of Long)
C# 
public static readonly ISerializer<long> Int64

Example

Library/Library.Test/TestFragmentedFile.cs

C#Copy Code
using (SharedMemoryStream shared = new SharedMemoryStream())
using (FragmentedFile ff = FragmentedFile.CreateNew(shared, 512, 100, 2))
{
    long id = ff.Create();
    using (Stream write = ff.Open(id, FileAccess.Write))
    {
        Assert.IsFalse(write.CanRead);
        Assert.IsTrue(write.CanWrite);
        Assert.IsFalse(write.CanSeek);
        PrimitiveSerializer.Int64.WriteTo(id, write);
        write.Flush();//no-op

        AssertThrows<NotSupportedException>(delegate() { write.Position = 0; });
        AssertThrows<NotSupportedException>(delegate() { GC.KeepAlive(write.Position); });
        AssertThrows<NotSupportedException>(delegate() { GC.KeepAlive(write.Length); });
        AssertThrows<NotSupportedException>(delegate() { write.SetLength(1); });
        AssertThrows<NotSupportedException>(delegate() { write.Seek(1, SeekOrigin.Begin); });
        AssertThrows<NotSupportedException>(delegate() { write.ReadByte(); });
    }
}
VB.NETCopy Code
Using [shared] As New SharedMemoryStream()
    Using ff As FragmentedFile = FragmentedFile.CreateNew([shared], 512, 100, 2)
        Dim id As Long = ff.Create()
        Using write As Stream = ff.Open(id, FileAccess.Write)
            Assert.IsFalse(write.CanRead)
            Assert.IsTrue(write.CanWrite)
            Assert.IsFalse(write.CanSeek)
            PrimitiveSerializer.Int64.WriteTo(id, write)
            write.Flush()
            'no-op
            AssertThrows(Of NotSupportedException)(Function() Do
                write.Position = 0
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                GC.KeepAlive(write.Position)
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                GC.KeepAlive(write.Length)
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                write.SetLength(1)
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                write.Seek(1, SeekOrigin.Begin)
            End Function)
            AssertThrows(Of NotSupportedException)(Function() Do
                write.ReadByte()
            End Function)
        End Using
    End Using
End Using

Requirements

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

See Also

Generated with Document! X 2011 by Innovasys