Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// A custom extension method that helps transform from dotnet
        /// Dictionary&lt;string, object&gt; 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);
        }