本文整理汇总了C#中Geometry.ToLogicalBlockAddress方法的典型用法代码示例。如果您正苦于以下问题:C# Geometry.ToLogicalBlockAddress方法的具体用法?C# Geometry.ToLogicalBlockAddress怎么用?C# Geometry.ToLogicalBlockAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Geometry
的用法示例。
在下文中一共展示了Geometry.ToLogicalBlockAddress方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateByCylinder
public void CreateByCylinder()
{
SparseMemoryStream ms = new SparseMemoryStream();
Geometry geom = new Geometry(15, 30, 63);
ms.SetLength(geom.Capacity);
BiosPartitionTable table = BiosPartitionTable.Initialize(ms, geom);
Assert.AreEqual(0, table.CreatePrimaryByCylinder(0, 4, 33, false));
Assert.AreEqual(1, table.CreatePrimaryByCylinder(10, 14, 33, false));
Assert.AreEqual(geom.ToLogicalBlockAddress(new ChsAddress(0, 1, 1)), table[0].FirstSector);
Assert.AreEqual(geom.ToLogicalBlockAddress(new ChsAddress(5, 0, 1)) - 1, table[0].LastSector);
Assert.AreEqual(geom.ToLogicalBlockAddress(new ChsAddress(10, 0, 1)), table[1].FirstSector);
Assert.AreEqual(geom.ToLogicalBlockAddress(new ChsAddress(14, 29, 63)), table[1].LastSector);
}
示例2: CreateBySizeInGap
public void CreateBySizeInGap()
{
SparseMemoryStream ms = new SparseMemoryStream();
Geometry geom = new Geometry(15, 30, 63);
ms.SetLength(geom.Capacity);
BiosPartitionTable table = BiosPartitionTable.Initialize(ms, geom);
Assert.AreEqual(0, table.CreatePrimaryByCylinder(0, 4, 33, false));
Assert.AreEqual(1, table.CreatePrimaryByCylinder(10, 14, 33, false));
table.Create(geom.ToLogicalBlockAddress(new ChsAddress(4, 0, 1)) * 512, WellKnownPartitionType.WindowsFat, true);
}
示例3: CreateAligned
/// <summary>
/// Creates a new aligned partition that encompasses the entire disk.
/// </summary>
/// <param name="type">The partition type</param>
/// <param name="active">Whether the partition is active (bootable)</param>
/// <param name="alignment">The alignment (in bytes)</param>
/// <returns>The index of the partition</returns>
/// <remarks>The partition table must be empty before this method is called,
/// otherwise IOException is thrown.</remarks>
/// <remarks>
/// Traditionally partitions were aligned to the physical structure of the underlying disk,
/// however with modern storage greater efficiency is acheived by aligning partitions on
/// large values that are a power of two.
/// </remarks>
public override int CreateAligned(WellKnownPartitionType type, bool active, int alignment)
{
Geometry allocationGeometry = new Geometry(_diskData.Length, _diskGeometry.HeadsPerCylinder, _diskGeometry.SectorsPerTrack, _diskGeometry.BytesPerSector);
ChsAddress start = new ChsAddress(0, 1, 1);
long startLba = Utilities.RoundUp(allocationGeometry.ToLogicalBlockAddress(start), alignment / _diskGeometry.BytesPerSector);
long lastLba = Utilities.RoundDown((_diskData.Length / _diskGeometry.BytesPerSector), alignment / _diskGeometry.BytesPerSector);
return CreatePrimaryBySector(startLba, lastLba - 1, ConvertType(type, (lastLba - startLba) * Utilities.SectorSize), active);
}
示例4: Create
/// <summary>
/// Creates a new partition that encompasses the entire disk.
/// </summary>
/// <param name="type">The partition type</param>
/// <param name="active">Whether the partition is active (bootable)</param>
/// <returns>The index of the partition</returns>
/// <remarks>The partition table must be empty before this method is called,
/// otherwise IOException is thrown.</remarks>
public override int Create(WellKnownPartitionType type, bool active)
{
Geometry allocationGeometry = new Geometry(_diskData.Length, _diskGeometry.HeadsPerCylinder, _diskGeometry.SectorsPerTrack, _diskGeometry.BytesPerSector);
ChsAddress start = new ChsAddress(0, 1, 1);
ChsAddress last = allocationGeometry.LastSector;
long startLba = allocationGeometry.ToLogicalBlockAddress(start);
long lastLba = allocationGeometry.ToLogicalBlockAddress(last);
return CreatePrimaryByCylinder(0, allocationGeometry.Cylinders - 1, ConvertType(type, (lastLba - startLba) * Utilities.SectorSize), active);
}