Visual Basic (Declaration) | |
---|---|
Public Overloads Shared Function CreateNew( _ ByVal streamFactory As IFactory(Of Stream), _ ByVal blockSize As Integer, _ ByVal growthRate As Integer, _ ByVal cacheLimit As Integer _ ) As FragmentedFile |
C# | |
---|---|
public static FragmentedFile CreateNew( IFactory<Stream> streamFactory, int blockSize, int growthRate, int cacheLimit ) |
Parameters
- streamFactory
- blockSize
- growthRate
- cacheLimit
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.NET | Copy 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 |
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
Reference
FragmentedFile ClassFragmentedFile Members
Overload List
IFactory