Exemplo n.º 1
0
        /// <summary>
        /// Init new piano with these tones
        /// </summary>
        public Piano()
        {
            SoundCollection <char, Tuple <int, string> > source = new SoundCollection <char, Tuple <int, string> >();

            source.Add('a', new Tuple <int, string>(261, "C"));
            source.Add('s', new Tuple <int, string>(293, "D"));
            source.Add('d', new Tuple <int, string>(330, "E"));
            source.Add('f', new Tuple <int, string>(349, "F"));
            source.Add('g', new Tuple <int, string>(392, "G"));
            source.Add('h', new Tuple <int, string>(440, "A"));
            source.Add('j', new Tuple <int, string>(494, "H"));
            Collection.AddRange(source);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Add all records from one collection to this collection
 /// </summary>
 /// <param name="source">Source collection</param>
 /// <exception cref="ArgumentException">When we find a duplicate</exception>
 public void AddRange(SoundCollection <TKey, Tuple> source)
 {
     if (source == null)
     {
         throw new ArgumentNullException("SoundCollection is null");
     }
     source.ToList().ForEach(x =>
     {
         try
         {
             data.Add(x.Key, x.Value);
         }
         catch (ArgumentException ex)
         {
             Console.WriteLine("Value with the same key already exists in dictionary. {0}", ex);
         }
     });
 }