Fix serialization of UID values

This commit is contained in:
Frederik Carlier
2018-06-19 17:13:34 +02:00
parent 5797a92d91
commit 22fbc6afa5

View File

@@ -265,6 +265,7 @@ namespace Claunia.PropertyList
Indent(xml, level);
xml.Append("<string>");
Span<byte> bytes = stackalloc byte[this.length];
this.GetBytes(bytes);
foreach (byte b in bytes)
xml.Append(String.Format("{0:x2}", b));
xml.Append("</string>");
@@ -274,6 +275,7 @@ namespace Claunia.PropertyList
{
outPlist.Write(0x80 + this.length - 1);
Span<byte> bytes = stackalloc byte[this.length];
this.GetBytes(bytes);
outPlist.Write(bytes);
}
@@ -282,6 +284,7 @@ namespace Claunia.PropertyList
Indent(ascii, level);
ascii.Append("\"");
Span<byte> bytes = stackalloc byte[this.length];
this.GetBytes(bytes);
foreach (byte b in bytes)
ascii.Append(String.Format("{0:x2}", b));
ascii.Append("\"");
@@ -299,6 +302,12 @@ namespace Claunia.PropertyList
/// <returns><c>true</c> if the specified <see cref="Claunia.PropertyList.NSObject"/> is equal to the current
/// <see cref="Claunia.PropertyList.UID"/>; otherwise, <c>false</c>.</returns>
public override bool Equals(NSObject obj)
{
return Equals((object)obj);
}
/// <inheritdoc/>
public override bool Equals(object obj)
{
var uid = obj as UID;
@@ -309,6 +318,13 @@ namespace Claunia.PropertyList
&& uid.length == length
&& uid.value == value;
}
#if HAS_HASHCODE
public override int GetHashCode()
{
return HashCode.Combine(this.name, this.length, this.value);
}
#endif
}
}