From 4ae00a54cb462a14a510da4382a968b8c4744828 Mon Sep 17 00:00:00 2001 From: Frederik Carlier Date: Wed, 12 Jun 2019 14:51:29 +0200 Subject: [PATCH] Add UID.ToUInt64() --- plist-cil.test/UIDTests.cs | 6 ++++++ plist-cil/UID.cs | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/plist-cil.test/UIDTests.cs b/plist-cil.test/UIDTests.cs index a9e6bcd..cc309d7 100644 --- a/plist-cil.test/UIDTests.cs +++ b/plist-cil.test/UIDTests.cs @@ -36,6 +36,7 @@ namespace plistcil.test { UID uid = new UID(0xAB); Assert.Equal(new byte[] {0xAB}, uid.Bytes); + Assert.Equal(0xABu, uid.ToUInt64()); } [Fact] @@ -43,6 +44,7 @@ namespace plistcil.test { UID uid = new UID(0xABCDEF00); Assert.Equal(new byte[] {0xAB, 0xCD, 0xEF, 0x00}, uid.Bytes); + Assert.Equal(0xABCDEF00, uid.ToUInt64()); } [Fact] @@ -50,6 +52,7 @@ namespace plistcil.test { UID uid = new UID(0xABCDEF0000EFCDAB); Assert.Equal(new byte[] {0xAB, 0xCD, 0xEF, 0x00, 0x00, 0xEF, 0xCD, 0xAB}, uid.Bytes); + Assert.Equal(0xABCDEF0000EFCDAB, uid.ToUInt64()); } [Fact] @@ -71,6 +74,7 @@ namespace plistcil.test { UID uid = new UID(0xABCDEF00u); Assert.Equal(new byte[] {0xAB, 0xCD, 0xEF, 0x00}, uid.Bytes); + Assert.Equal(0xABCDEF00u, uid.ToUInt64()); } [Fact] @@ -78,6 +82,7 @@ namespace plistcil.test { UID uid = new UID(0xABCDEF0000EFCDABu); Assert.Equal(new byte[] {0xAB, 0xCD, 0xEF, 0x00, 0x00, 0xEF, 0xCD, 0xAB}, uid.Bytes); + Assert.Equal(0xABCDEF0000EFCDABu, uid.ToUInt64()); } [Fact] @@ -85,6 +90,7 @@ namespace plistcil.test { UID uid = new UID(0xABCDu); Assert.Equal(new byte[] {0xAB, 0xCD}, uid.Bytes); + Assert.Equal(0xABCDu, uid.ToUInt64()); } [Fact] diff --git a/plist-cil/UID.cs b/plist-cil/UID.cs index cf21b5c..d092849 100644 --- a/plist-cil/UID.cs +++ b/plist-cil/UID.cs @@ -333,5 +333,16 @@ namespace Claunia.PropertyList { return $"{value} (UID)"; } + + /// + /// Gets a which represents this . + /// + /// + /// A which represents this . + /// + public ulong ToUInt64() + { + return this.value; + } } } \ No newline at end of file