CSharpTest.Net
TransactedCompoundFile.Options Class
Members  Example  See Also  Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : TransactedCompoundFile.Options Class

Glossary Item Box

Advanced Options used to construct a TransactedCompoundFile

Syntax

Visual Basic (Declaration) 
Public Class TransactedCompoundFile.Options 
C# 
public class TransactedCompoundFile.Options 

Example

Library/Library.Test/TestTransactedCompoundFile.cs

C#Copy Code
Dictionary<uint, byte[]> store = new Dictionary<uint, byte[]>();
using (TempFile temp = new TempFile())
{
    uint id;
    byte[] bytes;
    using (TransactedCompoundFile test = new TransactedCompoundFile(new TransactedCompoundFile.Options(temp.TempPath) { BlockSize = 512, CreateNew = true }))
    {
        for (int i = 0; i < 10000; i++)
        {
            switch(i < 1000 ? 0 : rand.Next(3))
            {
                case 0:
                    {
                        id = test.Create();
                        bytes = RandomBytes(rand.Next(1000));
                        store.Add(id, bytes);
                        test.Write(id, bytes, 0, bytes.Length);
                        break;
                    }
                case 1:
                    {
                        id = RandomPick(store.Keys);
                        bytes = store[id];
                        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(id)));
                        break;
                    }
                case 2:
                    {
                        id = RandomPick(store.Keys);
                        Assert.IsTrue(store.Remove(id));
                        test.Delete(id);
                        break;
                    }
            }
        }

        foreach (var kv in store)
        {
            CompareBytes(kv.Value, 0, kv.Value.Length, IOStream.ReadAllBytes(test.Read(kv.Key)));
        }
    }
}
VB.NETCopy Code
Dim store As New Dictionary(Of UInteger, Byte())()
Using temp As New TempFile()
    Dim id As UInteger
    Dim bytes As Byte()
    Using test As New TransactedCompoundFile(New TransactedCompoundFile.Options(temp.TempPath) With { _
        Key .BlockSize = 512, _
        Key .CreateNew = True _
    })
        Dim i As Integer = 0
        While i < 10000
            Select Case If(i < 1000, 0, rand.[Next](3))
                Case 0
                    If True Then
                        id = test.Create()
                        bytes = RandomBytes(rand.[Next](1000))
                        store.Add(id, bytes)
                        test.Write(id, bytes, 0, bytes.Length)
                        Exit Select
                    End If
                Case 1
                    If True Then
                        id = RandomPick(store.Keys)
                        bytes = store(id)
                        CompareBytes(bytes, 0, bytes.Length, IOStream.ReadAllBytes(test.Read(id)))
                        Exit Select
                    End If
                Case 2
                    If True Then
                        id = RandomPick(store.Keys)
                        Assert.IsTrue(store.Remove(id))
                        test.Delete(id)
                        Exit Select
                    End If
            End Select
            System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
        End While

        For Each kv As var In store
            CompareBytes(kv.Value, 0, kv.Value.Length, IOStream.ReadAllBytes(test.Read(kv.Key)))
        Next
    End Using
End Using

Inheritance Hierarchy

System.Object
   CSharpTest.Net.IO.TransactedCompoundFile.Options

Requirements

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

See Also

Generated with Document! X 2011 by Innovasys