public static HashMap ToHashMap(this IDictionary <object, object> dictionary) { var map = new HashMap(); dictionary.ToList().ForEach(x => map.Put(x.Key, x.Value)); return(map); }
/// <summary> /// A custom extension method that helps transform from dotnet /// Dictionary<string, object> to java.util.HashMap. /// </summary> /// <param name="dictionary">a Dictionary instance</param> /// <returns><see cref="HashMap"/></returns> internal static HashMap ToJavaHashMap(this Dictionary <string, object> dictionary) { var hashMap = new HashMap(SparkEnvironment.JvmBridge); foreach (KeyValuePair <string, object> item in dictionary) { hashMap.Put(item.Key, item.Value); } return(hashMap); }