Merge pull request #58 from quamotion/fixes/uid-touint64

Add UID.ToUInt64() method
This commit is contained in:
2019-06-12 18:37:08 +01:00
committed by GitHub
2 changed files with 17 additions and 0 deletions

View File

@@ -36,6 +36,7 @@ namespace plistcil.test
{ {
UID uid = new UID(0xAB); UID uid = new UID(0xAB);
Assert.Equal(new byte[] {0xAB}, uid.Bytes); Assert.Equal(new byte[] {0xAB}, uid.Bytes);
Assert.Equal(0xABu, uid.ToUInt64());
} }
[Fact] [Fact]
@@ -43,6 +44,7 @@ namespace plistcil.test
{ {
UID uid = new UID(0xABCDEF00); UID uid = new UID(0xABCDEF00);
Assert.Equal(new byte[] {0xAB, 0xCD, 0xEF, 0x00}, uid.Bytes); Assert.Equal(new byte[] {0xAB, 0xCD, 0xEF, 0x00}, uid.Bytes);
Assert.Equal(0xABCDEF00, uid.ToUInt64());
} }
[Fact] [Fact]
@@ -50,6 +52,7 @@ namespace plistcil.test
{ {
UID uid = new UID(0xABCDEF0000EFCDAB); UID uid = new UID(0xABCDEF0000EFCDAB);
Assert.Equal(new byte[] {0xAB, 0xCD, 0xEF, 0x00, 0x00, 0xEF, 0xCD, 0xAB}, uid.Bytes); Assert.Equal(new byte[] {0xAB, 0xCD, 0xEF, 0x00, 0x00, 0xEF, 0xCD, 0xAB}, uid.Bytes);
Assert.Equal(0xABCDEF0000EFCDAB, uid.ToUInt64());
} }
[Fact] [Fact]
@@ -57,6 +60,7 @@ namespace plistcil.test
{ {
UID uid = new UID(0xABCDEF00u); UID uid = new UID(0xABCDEF00u);
Assert.Equal(new byte[] {0xAB, 0xCD, 0xEF, 0x00}, uid.Bytes); Assert.Equal(new byte[] {0xAB, 0xCD, 0xEF, 0x00}, uid.Bytes);
Assert.Equal(0xABCDEF00u, uid.ToUInt64());
} }
[Fact] [Fact]
@@ -64,6 +68,7 @@ namespace plistcil.test
{ {
UID uid = new UID(0xABCDEF0000EFCDABu); UID uid = new UID(0xABCDEF0000EFCDABu);
Assert.Equal(new byte[] {0xAB, 0xCD, 0xEF, 0x00, 0x00, 0xEF, 0xCD, 0xAB}, uid.Bytes); Assert.Equal(new byte[] {0xAB, 0xCD, 0xEF, 0x00, 0x00, 0xEF, 0xCD, 0xAB}, uid.Bytes);
Assert.Equal(0xABCDEF0000EFCDABu, uid.ToUInt64());
} }
[Fact] [Fact]
@@ -71,6 +76,7 @@ namespace plistcil.test
{ {
UID uid = new UID(0xABCDu); UID uid = new UID(0xABCDu);
Assert.Equal(new byte[] {0xAB, 0xCD}, uid.Bytes); Assert.Equal(new byte[] {0xAB, 0xCD}, uid.Bytes);
Assert.Equal(0xABCDu, uid.ToUInt64());
} }
[Fact] [Fact]

View File

@@ -224,5 +224,16 @@ namespace Claunia.PropertyList
{ {
return $"{value} (UID)"; return $"{value} (UID)";
} }
/// <summary>
/// Gets a <see cref="ulong"/> which represents this <see cref="UID"/>.
/// </summary>
/// <returns>
/// A <see cref="ulong"/> which represents this <see cref="UID"/>.
/// </returns>
public ulong ToUInt64()
{
return this.value;
}
} }
} }