mirror of
https://github.com/claunia/plist-cil.git
synced 2025-12-16 19:14:26 +00:00
Merge pull request #65 from quamotion/fixes/uid-xml
Update XML representation of UIDs
This commit is contained in:
@@ -86,10 +86,11 @@ namespace plistcil.test
|
|||||||
|
|
||||||
string plist = original.ToXmlPropertyList();
|
string plist = original.ToXmlPropertyList();
|
||||||
|
|
||||||
// UIDs don't exist in XML property lists, but they are represented as strings
|
// UIDs don't exist in XML property lists, but they are represented as dictionaries
|
||||||
// for compability purposes
|
// for compability purposes
|
||||||
NSString roundtrip = XmlPropertyListParser.ParseString(plist) as NSString;
|
var roundtrip = XmlPropertyListParser.ParseString(plist) as NSDictionary;
|
||||||
Assert.Equal("abcd", roundtrip.ToObject());
|
Assert.Single(roundtrip.Keys, "CF$UID");
|
||||||
|
Assert.Single(roundtrip.Values, new NSNumber(0xabcd));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -148,19 +148,28 @@ namespace Claunia.PropertyList
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// There is no XML representation specified for UIDs.
|
/// UIDs are represented as dictionaries in XML property lists,
|
||||||
/// In this implementation UIDs are represented as strings in the XML output.
|
/// where the key is always <c>CF$UID</c> and the value is the integer
|
||||||
|
/// representation of the UID.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="xml">The xml StringBuilder</param>
|
/// <param name="xml">The xml StringBuilder</param>
|
||||||
/// <param name="level">The indentation level</param>
|
/// <param name="level">The indentation level</param>
|
||||||
internal override void ToXml(StringBuilder xml, int level)
|
internal override void ToXml(StringBuilder xml, int level)
|
||||||
{
|
{
|
||||||
Indent(xml, level);
|
Indent(xml, level);
|
||||||
xml.Append("<string>");
|
xml.Append("<dict>");
|
||||||
Span<byte> bytes = stackalloc byte[ByteCount];
|
xml.AppendLine();
|
||||||
GetBytes(bytes);
|
|
||||||
foreach(byte b in bytes) xml.Append(string.Format("{0:x2}", b));
|
Indent(xml, level + 1);
|
||||||
xml.Append("</string>");
|
xml.Append("<key>CF$UID</key>");
|
||||||
|
xml.AppendLine();
|
||||||
|
|
||||||
|
Indent(xml, level + 1);
|
||||||
|
xml.Append($"<integer>{this.value}</integer>");
|
||||||
|
xml.AppendLine();
|
||||||
|
|
||||||
|
Indent(xml, level);
|
||||||
|
xml.Append("</dict>");
|
||||||
}
|
}
|
||||||
|
|
||||||
internal override void ToBinary(BinaryPropertyListWriter outPlist)
|
internal override void ToBinary(BinaryPropertyListWriter outPlist)
|
||||||
|
|||||||
Reference in New Issue
Block a user