mirror of
https://github.com/claunia/plist-cil.git
synced 2025-12-16 19:14:26 +00:00
Merge pull request #66 from quamotion/fixes/xml-uid-deserialize
XmlPropertyListParser: Support deserializing UID values
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
image: Visual Studio 2019
|
||||||
|
|
||||||
build_script:
|
build_script:
|
||||||
- cmd: dotnet build -c Release --version-suffix r%APPVEYOR_BUILD_NUMBER%
|
- cmd: dotnet build -c Release --version-suffix r%APPVEYOR_BUILD_NUMBER%
|
||||||
- cmd: dotnet test plist-cil.test\plist-cil.test.csproj
|
- cmd: dotnet test plist-cil.test\plist-cil.test.csproj
|
||||||
|
|||||||
@@ -88,9 +88,8 @@ namespace plistcil.test
|
|||||||
|
|
||||||
// UIDs don't exist in XML property lists, but they are represented as dictionaries
|
// UIDs don't exist in XML property lists, but they are represented as dictionaries
|
||||||
// for compability purposes
|
// for compability purposes
|
||||||
var roundtrip = XmlPropertyListParser.ParseString(plist) as NSDictionary;
|
var roundtrip = XmlPropertyListParser.ParseString(plist) as UID;
|
||||||
Assert.Single(roundtrip.Keys, "CF$UID");
|
Assert.Equal(0xabcdUL, roundtrip.ToUInt64());
|
||||||
Assert.Single(roundtrip.Values, new NSNumber(0xabcd));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -147,19 +147,31 @@ namespace Claunia.PropertyList
|
|||||||
{
|
{
|
||||||
if(n.Name.Equals("dict"))
|
if(n.Name.Equals("dict"))
|
||||||
{
|
{
|
||||||
NSDictionary dict = new NSDictionary();
|
// Special case for UID values
|
||||||
List<XmlNode> children = FilterElementNodes(n.ChildNodes);
|
if(n.ChildNodes.Count == 2
|
||||||
for(int i = 0; i < children.Count; i += 2)
|
&& n.ChildNodes[0].Name == "key"
|
||||||
|
&& n.ChildNodes[0].InnerText == "CF$UID"
|
||||||
|
&& n.ChildNodes[1].Name == "integer"
|
||||||
|
&& uint.TryParse(n.ChildNodes[1].InnerText, out uint uidValue))
|
||||||
{
|
{
|
||||||
XmlNode key = children[i];
|
return new UID(uidValue);
|
||||||
XmlNode val = children[i + 1];
|
|
||||||
|
|
||||||
string keyString = GetNodeTextContents(key);
|
|
||||||
|
|
||||||
dict.Add(keyString, ParseObject(val));
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSDictionary dict = new NSDictionary();
|
||||||
|
List<XmlNode> children = FilterElementNodes(n.ChildNodes);
|
||||||
|
for(int i = 0; i < children.Count; i += 2)
|
||||||
|
{
|
||||||
|
XmlNode key = children[i];
|
||||||
|
XmlNode val = children[i + 1];
|
||||||
|
|
||||||
return dict;
|
string keyString = GetNodeTextContents(key);
|
||||||
|
|
||||||
|
dict.Add(keyString, ParseObject(val));
|
||||||
|
}
|
||||||
|
|
||||||
|
return dict;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(n.Name.Equals("array"))
|
if(n.Name.Equals("array"))
|
||||||
|
|||||||
Reference in New Issue
Block a user