mirror of
https://github.com/claunia/plist-cil.git
synced 2025-12-16 11:04:26 +00:00
Compare commits
2 Commits
cf62f6c3d1
...
7939141dc3
| Author | SHA1 | Date | |
|---|---|---|---|
| 7939141dc3 | |||
|
|
742e1fa57a |
@@ -1,4 +1,4 @@
|
||||
// plist-cil - An open source library to Parse and generate property lists for .NET
|
||||
// plist-cil - An open source library to Parse and generate property lists for .NET
|
||||
// Copyright (C) 2015 Natalia Portillo
|
||||
//
|
||||
// This code is based on:
|
||||
@@ -209,6 +209,16 @@ namespace plistcil.test
|
||||
map.Add("long", lng);
|
||||
map.Add("date", date);
|
||||
|
||||
List<Dictionary<string,object>> listOfMaps = new()
|
||||
{
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{ "int", i },
|
||||
{ "long", lng },
|
||||
{ "date", date }
|
||||
}
|
||||
};
|
||||
|
||||
var WrappedO = NSObject.Wrap((object)bl);
|
||||
Assert.True(WrappedO is (NSNumber));
|
||||
Assert.True(WrappedO.ToObject().Equals(bl));
|
||||
@@ -274,6 +284,15 @@ namespace plistcil.test
|
||||
Assert.True(((NSNumber)dict.ObjectForKey("long")).ToLong() == lng);
|
||||
Assert.True(((NSDate)dict.ObjectForKey("date")).Date.Equals(date));
|
||||
|
||||
WrappedO = NSObject.Wrap((object)listOfMaps);
|
||||
Assert.True(WrappedO is (NSArray));
|
||||
var arrayOfMaps = (NSArray)WrappedO;
|
||||
Assert.True(arrayOfMaps.Count == 1);
|
||||
var firstMap = (NSDictionary)arrayOfMaps[0];
|
||||
Assert.True(((NSNumber)firstMap.ObjectForKey("int")).ToLong() == i);
|
||||
Assert.True(((NSNumber)firstMap.ObjectForKey("long")).ToLong() == lng);
|
||||
Assert.True(((NSDate)firstMap.ObjectForKey("date")).Date.Equals(date));
|
||||
|
||||
// TODO
|
||||
/*
|
||||
Object unWrappedO = WrappedO.ToObject();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// plist-cil - An open source library to parse and generate property lists for .NET
|
||||
// plist-cil - An open source library to parse and generate property lists for .NET
|
||||
// Copyright (C) 2015 Natalia Portillo
|
||||
//
|
||||
// This code is based on:
|
||||
@@ -321,6 +321,14 @@ namespace Claunia.PropertyList
|
||||
if(typeof(List<object>).IsAssignableFrom(c))
|
||||
return Wrap(((List<object>)o).ToArray());
|
||||
|
||||
if(typeof(List<Dictionary<string, object>>).IsAssignableFrom(c))
|
||||
{
|
||||
var list = new NSArray();
|
||||
foreach(Dictionary<string, object> dict in (List<Dictionary<string, object>>)o)
|
||||
list.Add(Wrap(dict));
|
||||
return list;
|
||||
}
|
||||
|
||||
throw new PropertyListException($"Cannot wrap an object of type {o.GetType().Name}.");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user