示例#1
0
        public void Dump()
        {
            Console.WriteLine();
            var list1 = externalServices.GetState();
            var list2 = localDB.GetState();
            var keys  = list1.Select(o => o.Key).Concat(list2.Select(o => o.Key)).Distinct();

            foreach (var key in keys)
            {
                var values1 = list1.FirstOrDefault(o => o.Key == key).Value ?? Enumerable.Empty <double>();
                var values2 = list2.FirstOrDefault(o => o.Key == key).Value ?? Enumerable.Empty <double>();

                if (values1.Sum() == values2.Sum())
                {
                    Console.BackgroundColor = ConsoleColor.Green;
                }
                else
                {
                    Console.BackgroundColor = ConsoleColor.Red;
                }
                Console.ForegroundColor = ConsoleColor.Black;
                Console.Write($" {key} ");
                Console.ResetColor();

                var list = values1.Intersect(values2);
                Console.ForegroundColor = ConsoleColor.Green;
                if (list.Any())
                {
                    Console.Write($" {string.Join(" ", list)}");
                }
                Console.ForegroundColor = ConsoleColor.Red;
                list = values1.Except(values2);
                if (list.Any())
                {
                    Console.Write($" EXT ONLY: {string.Join(" ", list)}");
                }
                Console.ForegroundColor = ConsoleColor.Yellow;
                list = values2.Except(values1);
                if (list.Any())
                {
                    Console.Write($" LOC ONLY: {string.Join(" ", list)}");
                }
                Console.ResetColor();
                Console.WriteLine();
            }
        }