예제 #1
0
파일: Program.cs 프로젝트: jplopes/Patterns
        private static void Main(string[] args)
        {
            const string ZipCode = "SeattleZipCode";

            ITemperatureService temperatureService = new TemperatureService();
            LocalTemperature    localTemp          = temperatureService.GetTemperature(ZipCode);

            Console.WriteLine(
                "The current temperature is {0:F1}F/{1:F1}C. in {2}, {3}",
                localTemp.Farenheit,
                localTemp.Celcius,
                localTemp.City,
                localTemp.State);

            Console.ReadKey();
        }
예제 #2
0
        public LocalTemperature GetTemperature(string zipCode)
        {
            var coords = geoLookupService.GetCoordinatesForZipCode(zipCode);
            var city   = geoLookupService.GetCityForZipCode(zipCode);
            var state  = geoLookupService.GetStateForZipCode(zipCode);

            var farenheit = weatherService.GetTempFarenheit(coords.Latitude, coords.Longitude);
            var celcius   = converter.FarenheitToCelcious(farenheit);

            var localTemperature = new LocalTemperature()
            {
                Farenheit = farenheit,
                Celcius   = celcius,
                City      = city,
                State     = state
            };

            return(localTemperature);
        }