Example #1
0
        /// <summary>
        /// Initializes a instance of the <see cref="KeyMap"/> class with the entries
        /// from another <see cref="KeyMap"/>.
        /// </summary>
        /// <param name="source">The source map that will be cloned.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="source"/> is <see langword="null"/>.
        /// </exception>
        public KeyMap(KeyMap source)
        {
            if (source == null)
            throw new ArgumentNullException("source");

              // Clone the source KeyMap.
              foreach (KeyValuePair<int, Dictionary<int, char>> entry in source._map)
              {
            var sourceKey = entry.Key;
            var sourceKeyVariants = entry.Value;

            var keyVariants = new Dictionary<int, char>();
            foreach (var keyVariant in sourceKeyVariants)
              keyVariants.Add(keyVariant.Key, keyVariant.Value);

            _map.Add(sourceKey, keyVariants);
              }
        }
Example #2
0
        /// <summary>
        /// Initializes a instance of the <see cref="KeyMap"/> class with the entries
        /// from another <see cref="KeyMap"/>.
        /// </summary>
        /// <param name="source">The source map that will be cloned.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="source"/> is <see langword="null"/>.
        /// </exception>
        public KeyMap(KeyMap source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            // Clone the source KeyMap.
            foreach (KeyValuePair <int, Dictionary <int, char> > entry in source._map)
            {
                var sourceKey         = entry.Key;
                var sourceKeyVariants = entry.Value;

                var keyVariants = new Dictionary <int, char>();
                foreach (var keyVariant in sourceKeyVariants)
                {
                    keyVariants.Add(keyVariant.Key, keyVariant.Value);
                }

                _map.Add(sourceKey, keyVariants);
            }
        }