コード例 #1
0
        /// <summary>
        /// Constructor adds items to the top-level menu
        /// </summary>
        public CountryMenu(Country country, ICityDAO cityDAO, ICountryLanguageDAO countryLanguageDAO)
        {
            // Update this constructor to accept appropriate daos, and save them in local variables.
            this.cityDAO            = cityDAO;
            this.countryLanguageDAO = countryLanguageDAO;

            // Save the country (which will be used for all country queries
            this.country = country;

            // This code is just protection because before we complete the code, Country may be null
            if (country == null)
            {
                country = new Country();
            }

            // Add options to this menu
            AddOption($"List Cities in {country.Name}", ListCities)
            .AddOption($"List Languages in {country.Name}", ListLanguages)
            .AddOption($"Add a city to {country.Name}", AddCity)
            .AddOption("Remove a city", RemoveCity)
            .AddOption("Back", Exit);

            Configure(cfg =>
            {
                cfg.ItemForegroundColor         = ConsoleColor.DarkGreen;
                cfg.SelectedItemForegroundColor = ConsoleColor.Green;
            });
        }
コード例 #2
0
        /// <summary>
        /// Constructor adds items to the top-level menu
        /// </summary>
        public WorldDBMenu(ICountryDAO countryDAO, ICityDAO cityDAO, ICountryLanguageDAO countryLanguageDAO)
        {
            // This constructor requires country dao
            // This constructor requires country-language dao

            // Assign the Interfaces to protected variables so we can use them later
            this.countryDAO         = countryDAO;
            this.cityDAO            = cityDAO;
            this.countryLanguageDAO = countryLanguageDAO;

            // Add options to this menu
            AddOption("List Countries", ListCountries)
            .AddOption("List Countries on a continent", ListCountriesForContinent)
            .AddOption("Select a country", SelectACountry)
            .AddOption("Quit", Exit);

            Configure(cfg =>
            {
                cfg.ItemForegroundColor         = ConsoleColor.Yellow;
                cfg.SelectedItemForegroundColor = ConsoleColor.Green;
            });
        }