diff --git a/XCPlist.cs b/XCPlist.cs index d3ff503..d8e9399 100644 --- a/XCPlist.cs +++ b/XCPlist.cs @@ -41,14 +41,34 @@ public void Process(Hashtable plist) } } - // http://stackoverflow.com/questions/20618809/hashtable-to-dictionary - public static Dictionary HashtableToDictionary (Hashtable table) - { - Dictionary dict = new Dictionary(); - foreach(DictionaryEntry kvp in table) - dict.Add((K)kvp.Key, (V)kvp.Value); - return dict; - } + private object formatPListObject(object value) + { + if (value is ArrayList) + { + ArrayList arrayList = (ArrayList)value; + + List list = new List(); + foreach (var obj in arrayList) + { + list.Add(formatPListObject(obj)); + } + return list; + } + + if (value is Hashtable) + { + Hashtable hashTable = (Hashtable)value; + + Dictionary dic = new Dictionary(); + foreach (DictionaryEntry entry in hashTable) + { + dic.Add(entry.Key.ToString(), formatPListObject(entry.Value)); + } + return dic; + } + + return value; + } public void AddPlistItems(string key, object value, Dictionary dict) { @@ -60,8 +80,8 @@ public void AddPlistItems(string key, object value, Dictionary d } else { - dict[key] = HashtableToDictionary((Hashtable)value); - plistModified = true; + dict[key] = formatPListObject(value); + plistModified = true; } }