CSharpTest.Net
DisposingList Constructor()
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > DisposingList Class > DisposingList Constructor : DisposingList Constructor()

Glossary Item Box

Initializes a new instance of the System.Collections.Generic.List>T> class that is empty and has the default initial capacity.

Syntax

Visual Basic (Declaration) 
Public Function New()
C# 
public DisposingList()

Example

Library/Library.Test/TestReplaceFile.cs

C#Copy Code
string path;
using(DisposingList l = new DisposingList())
{
    TempFile ftarget = new TempFile();
    ftarget.Delete();

    l.Add(ftarget);
    TempFile fbigone = TempFile.Attach(String.Format("{0}.~{1:x4}", ftarget.TempPath, 0x10008 - 25));
    fbigone.Create().Dispose();
    Assert.IsTrue(fbigone.Exists);
    l.Add(fbigone);
    path = ftarget.TempPath;

    string tmpName;
    Dictionary<string, object> names = new Dictionary<string,object>(StringComparer.OrdinalIgnoreCase);

    for( int i=0; i < 25; i++ )
    {
        Stream s = ReplaceFile.CreateDerivedFile(ftarget.TempPath, out tmpName);
        l.Add(TempFile.Attach(tmpName));
        l.Add(s);
        names.Add(tmpName, null);
    }
    
    fbigone.Delete();
    Assert.AreEqual(25, Directory.GetFiles(Path.GetDirectoryName(path), Path.GetFileName(path) + "*").Length);
}
Assert.AreEqual(0, Directory.GetFiles(Path.GetDirectoryName(path), Path.GetFileName(path) + "*").Length);
VB.NETCopy Code
Dim path As String
Using l As New DisposingList()
    Dim ftarget As New TempFile()
    ftarget.Delete()

    l.Add(ftarget)
    Dim fbigone As TempFile = TempFile.Attach([String].Format("{0}.~{1:x4}", ftarget.TempPath, &H10008 - 25))
    fbigone.Create().Dispose()
    Assert.IsTrue(fbigone.Exists)
    l.Add(fbigone)
    path = ftarget.TempPath

    Dim tmpName As String
    Dim names As New Dictionary(Of String, Object)(StringComparer.OrdinalIgnoreCase)

    Dim i As Integer = 0
    While i < 25
        Dim s As Stream = ReplaceFile.CreateDerivedFile(ftarget.TempPath, tmpName)
        l.Add(TempFile.Attach(tmpName))
        l.Add(s)
        names.Add(tmpName, Nothing)
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While

    fbigone.Delete()
    Assert.AreEqual(25, Directory.GetFiles(Path.GetDirectoryName(path), Path.GetFileName(path) + "*").Length)
End Using
Assert.AreEqual(0, Directory.GetFiles(Path.GetDirectoryName(path), Path.GetFileName(path) + "*").Length)

Requirements

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

See Also

Generated with Document! X 2011 by Innovasys