コード例 #1
0
ファイル: Program.cs プロジェクト: codeinclined/Lab08-LINQ
        static void Main(string[] args)
        {
            const string dataPath       = @"..\..\..\..\data.json";
            string       horizontalLine = new string('\u2550', Console.WindowWidth - 1);

            FeatureCollection fc = JsonConvert.DeserializeObject <FeatureCollection>(
                File.ReadAllText(dataPath));

            // Display all of the neighborhoods mentioned in data.json
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine($"All neighborhoods in {dataPath}:");
            Console.WriteLine(horizontalLine);

            Console.ForegroundColor = ConsoleColor.White;
            string[] neighborhoods = fc.GetAllNeighborhoods();
            DisplayStringsInTwoColumns(neighborhoods);
            Console.Clear();

            // Display all of the non-empty neighborhoods in data.json
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine($"All non-empty neighborhoods in {dataPath}:");
            Console.WriteLine(horizontalLine);

            Console.ForegroundColor = ConsoleColor.White;
            neighborhoods           = fc.GetAllNonEmptyNeighborHoods();
            DisplayStringsInTwoColumns(neighborhoods);
            Console.Clear();

            // Display all of the unique, non-empty neighborhoods in data.json
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine($"All unique, non-empty neighborhoods in {dataPath}:");
            Console.WriteLine(horizontalLine);

            Console.ForegroundColor = ConsoleColor.White;
            neighborhoods           = fc.GetAllUniqueNonEmptyNeighborhoods();
            DisplayStringsInTwoColumns(neighborhoods);
            Console.Clear();

            // Display all of the unique, non-empty neighboords in data.json as one single query
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine($"All unique, non-empty neighborhoods in {dataPath} as one query:");
            Console.WriteLine(horizontalLine);

            Console.ForegroundColor = ConsoleColor.White;
            neighborhoods           = fc.GetAllUniqueNonEmptyNeighborhoodsConsolidated();
            DisplayStringsInTwoColumns(neighborhoods);
            Console.Clear();
        }