123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- using System;
- namespace DiskAccessLibrary
- {
- public static class DiskImageCreator
- {
- public static DiskImage CreateImage(DiskImageFormat format, DiskImageType type, string imagePath, long imageSize, string snapshotPath, int blockSize)
- {
- switch (format)
- {
- case DiskImageFormat.BlockDifferencingDiskImage:
- switch (type)
- {
- case DiskImageType.Differencing:
- return BlockDifferencingDiskImage.Create(imagePath, snapshotPath, blockSize);
- case DiskImageType.Dynamic:
- return BlockDifferencingDiskImage.Create(snapshotPath, imageSize, blockSize);
- default:
- throw new ArgumentOutOfRangeException(nameof(type), type, null);
- }
- case DiskImageFormat.RawDiskImage:
- if (type != DiskImageType.Fixed) throw new NotSupportedException();
- return RawDiskImage.Create(imagePath, imageSize);
- case DiskImageFormat.VirtualHardDisk:
- switch (type)
- {
- case DiskImageType.Differencing:
- throw new NotSupportedException();
- case DiskImageType.Dynamic:
- return VirtualHardDisk.CreateDynamicDisk(imagePath, imageSize);
- case DiskImageType.Fixed:
- return VirtualHardDisk.CreateFixedDisk(imagePath, imageSize);
- default:
- throw new ArgumentOutOfRangeException(nameof(type), type, null);
- }
- default:
- throw new ArgumentOutOfRangeException(nameof(format), format, null);
- }
- }
- }
- }
|