public NSDictionary ConvertToNSDictionary(Dictionary<String,Object> dictionary) {
NSMutableDictionary prunedDictionary = new NSMutableDictionary();
foreach (String key in dictionary.Keys) {
Object dicValue = dictionary[key];
if (dicValue is Dictionary<String,Object>) {
prunedDictionary.Add (new NSString(key), ConvertToNSDictionary((dicValue as Dictionary<String,Object>)));
} else {
//SystemLogger.Log(SystemLogger.Module.PLATFORM, "***** key["+key+"] is instance of: " + dicValue.GetType().FullName);
if (dicValue != null) {
if(dicValue is String) {
prunedDictionary.Add (new NSString(key), new NSString((dicValue as String)));
} else if(dicValue is int) {
prunedDictionary.Add (new NSString(key), new NSNumber((int) dicValue));
} else if(dicValue is Object[]) {
prunedDictionary.Add (new NSString(key), ConvertToNSArray((Object[])dicValue));
} else if(dicValue is System.Collections.ArrayList) {
prunedDictionary.Add (new NSString(key), ConvertToNSArray((dicValue as System.Collections.ArrayList).ToArray()));
}else {
SystemLogger.Log(SystemLogger.Module.PLATFORM, "*** exception parsing key["+key+"] instance of: " + dicValue.GetType().FullName +". No complex object are valid inside this dictionary");
}
}
}
}
return prunedDictionary;
}