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

Glossary Item Box

Gets a typed version of the PrimitiveSerializer

Syntax

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

Example

BPlusTree/BPlusTree.Test/TestTransactionLog.cs

C#Copy Code
using (TempFile temp = new TempFile())
{
    temp.Delete();
    var opt = new TransactionLogOptions<int, string>(temp.TempPath,
                                                  PrimitiveSerializer.Int32,
                                                  PrimitiveSerializer.String);
    //FileName
    Assert.AreEqual(temp.TempPath, opt.FileName);
    //Key/Value serializers
    Assert.IsTrue(ReferenceEquals(opt.KeySerializer, PrimitiveSerializer.Int32));
    Assert.IsTrue(ReferenceEquals(opt.ValueSerializer, PrimitiveSerializer.String));
    //FileOptions
    Assert.AreEqual(FileOptions.WriteThrough, opt.FileOptions);
    Assert.AreEqual(FileOptions.WriteThrough | FileOptions.Asynchronous, opt.FileOptions |= FileOptions.Asynchronous);
    //Read Only
    Assert.AreEqual(false, opt.ReadOnly);
    Assert.AreEqual(true, opt.ReadOnly = true);
    //File Buffer
    Assert.AreEqual(8, opt.FileBuffer);
    Assert.AreEqual(0x40000, opt.FileBuffer = 0x40000);
    //Clone
    Assert.IsFalse(ReferenceEquals(opt, opt.Clone()));

    using(TransactionLog<int, string> log = new TransactionLog<int,string>(opt))
        Assert.AreEqual(0, log.Size);
}
VB.NETCopy Code
Using temp As New TempFile()
    temp.Delete()
    Dim opt As var = New TransactionLogOptions(Of Integer, String)(temp.TempPath, PrimitiveSerializer.Int32, PrimitiveSerializer.[String])
    'FileName
    Assert.AreEqual(temp.TempPath, opt.FileName)
    'Key/Value serializers
    Assert.IsTrue(ReferenceEquals(opt.KeySerializer, PrimitiveSerializer.Int32))
    Assert.IsTrue(ReferenceEquals(opt.ValueSerializer, PrimitiveSerializer.[String]))
    'FileOptions
    Assert.AreEqual(FileOptions.WriteThrough, opt.FileOptions)
    Assert.AreEqual(FileOptions.WriteThrough Or FileOptions.Asynchronous, opt.FileOptions = opt.FileOptions Or FileOptions.Asynchronous)
    'Read Only
    Assert.AreEqual(False, opt.[ReadOnly])
    Assert.AreEqual(True, opt.[ReadOnly] = True)
    'File Buffer
    Assert.AreEqual(8, opt.FileBuffer)
    Assert.AreEqual(&H40000, opt.FileBuffer = &H40000)
    'Clone
    Assert.IsFalse(ReferenceEquals(opt, opt.Clone()))

    Using log As New TransactionLog(Of Integer, String)(opt)
        Assert.AreEqual(0, log.Size)
    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

TestMultiInstance.TestSyncFromLogging()
TestTransactionLog.TestTransactionLogOptions()

Source Code

Library/Serialization/PrimitiveSerializer.cs

Generated with Document! X 2011 by Innovasys