Appverse.Core.iBeacon.BeaconUtils.ConvertToDictionary C# (CSharp) Method

ConvertToDictionary() public static method

public static ConvertToDictionary ( NSMutableDictionary dictionary ) : Object>.Dictionary
dictionary NSMutableDictionary
return Object>.Dictionary
		public static Dictionary<String,Object> ConvertToDictionary(NSMutableDictionary dictionary) {
			Dictionary<String,Object> prunedDictionary = new Dictionary<String,Object>();
			foreach (NSString key in dictionary.Keys) { 
				NSObject dicValue = dictionary.ObjectForKey(key);  

				if (dicValue is NSDictionary) {
					prunedDictionary.Add (key.ToString(), ConvertToDictionary(new NSMutableDictionary(dicValue as NSDictionary)));
				} else {
					//SystemLogger.Log(SystemLogger.Module.PLATFORM, "***** key["+key.ToString ()+"] is instance of: " + dicValue.GetType().FullName);
					if ( ! (dicValue is NSNull)) {
						if(dicValue is NSString) {
							prunedDictionary.Add (key.ToString(), ((NSString)dicValue).Description);
						} else if(dicValue is NSNumber) {
							prunedDictionary.Add (key.ToString(), ((NSNumber)dicValue).Int16Value);
						} else if(dicValue is NSArray) {
							prunedDictionary.Add (key.ToString(), ConvertToArray((NSArray)dicValue));
						} else {
							prunedDictionary.Add (key.ToString(), dicValue);
						}
					} 
				}
			}
			return prunedDictionary;
		}