コード例 #1
0
        public void InitializeFixedOwnStream()
        {
            MemoryStream ms = new MemoryStream();

            using (Disk disk = Disk.InitializeFixed(ms, Ownership.Dispose, 8 * 1024 * 1024))
            {
            }
            ms.ReadByte();
        }
コード例 #2
0
ファイル: DiskFactory.cs プロジェクト: radtek/USBInsanity
        public override VirtualDisk CreateDisk(FileLocator locator, string variant, string path, VirtualDiskParameters diskParameters)
        {
            switch (variant)
            {
            case "fixed":
                return(Disk.InitializeFixed(locator, path, diskParameters.Capacity, diskParameters.Geometry));

            case "dynamic":
                return(Disk.InitializeDynamic(locator, path, diskParameters.Capacity, diskParameters.Geometry, DynamicHeader.DefaultBlockSize));

            default:
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Unknown VHD disk variant '{0}'", variant), "variant");
            }
        }
コード例 #3
0
        public void InitializeFixed()
        {
            MemoryStream ms = new MemoryStream();

            using (Disk disk = Disk.InitializeFixed(ms, Ownership.None, 8 * 1024 * 1024))
            {
                Assert.IsNotNull(disk);
                Assert.That(disk.Geometry.Capacity > 7.5 * 1024 * 1024 && disk.Geometry.Capacity <= 8 * 1024 * 1024);
            }

            // Check the stream is still valid
            ms.ReadByte();
            ms.Dispose();
        }