コード例 #1
0
        static void Main(string[] args)
        {
            // Пример использования.
            var    dict            = new CompositeKeyDictionary <Person, Address, House>();
            var    ind             = 1;
            var    addressToSelect = new Address($"Country_{ind}", $"City{ind}", $"Street_{ind}", ind);
            Person personToSelect;

            FillDictionary(dict, out personToSelect);

            Console.WriteLine("All items:");
            foreach (var item in dict)
            {
                Console.WriteLine(item.ToString());
            }
            Console.WriteLine();

            Console.WriteLine($"Selected by address: {addressToSelect}");
            foreach (var item in dict.GetValuesByKey2(addressToSelect))
            {
                Console.WriteLine(item.ToString());
            }
            Console.WriteLine();

            Console.WriteLine($"Selected by person: {personToSelect}");
            foreach (var item in dict.GetValuesByKey1(personToSelect))
            {
                Console.WriteLine(item.ToString());
            }

            Console.ReadLine();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            // Пример использования. 
            var dict = new CompositeKeyDictionary<Person, Address, House>();
            var ind = 1;
            var addressToSelect = new Address($"Country_{ind}", $"City{ind}", $"Street_{ind}", ind);
            Person personToSelect;

            FillDictionary(dict, out personToSelect);

            Console.WriteLine("All items:");
            foreach (var item in dict)
            {
                Console.WriteLine(item.ToString());
            }
            Console.WriteLine();
           
            Console.WriteLine($"Selected by address: {addressToSelect}");
            foreach (var item in dict.GetValuesByKey2(addressToSelect))
            {
                Console.WriteLine(item.ToString());
            }
            Console.WriteLine();

            Console.WriteLine($"Selected by person: {personToSelect}");
            foreach (var item in dict.GetValuesByKey1(personToSelect))
            {
                Console.WriteLine(item.ToString());
            }

            Console.ReadLine();
        }
コード例 #3
0
 public void GetValuesByKey2_NoValue()
 {
     Assert.AreEqual(_dict.GetValuesByKey2(_firstAddr), Enumerable.Empty <House>());
 }