Ejemplo n.º 1
0
        protected void ButtonWeatherData_Click(object sender, EventArgs e)
        {
            ListBoxWeatherData.Items.Clear();
            WeatherServiceClient client = new WeatherServiceClient();
            string zipcode = validateAndReturnZipCode();

            if (zipcode != null)
            {
                ListBoxWeatherData.Items.Add("Max_Temp   |    Min_Temp");
                try
                {
                    String[] maxTemp = client.get_maxTempData(zipcode).Split(':');
                    String[] minTemp = client.get_minTempData(zipcode).Split(':');
                    for (int i = 0; i < maxTemp.Length; i++)
                    {
                        if (maxTemp[i].Equals("-273"))
                        {
                            maxTemp[i] = "NA";
                        }
                        if (minTemp[i].Equals("-273"))
                        {
                            minTemp[i] = "NA";
                        }
                        ListBoxWeatherData.Items.Add(maxTemp[i] + "------------------------" + minTemp[i]);
                    }
                }
                catch (Exception ex)
                {
                    String output = ex.Message;
                    ListBoxWeatherData.Items.Add(output);
                }
            }
        }
Ejemplo n.º 2
0
 static void Main(string[] args)
 {
     while (true)
     {
         WeatherServiceClient wc = new WeatherServiceClient();
         Console.WriteLine("Choose from the following opions");
         Console.WriteLine("1.celcius to farenheit");
         Console.WriteLine("2.farenheit to celcius");
         Console.WriteLine("3.Exit");
         int input = int.Parse(Console.ReadLine());
         if (input == 1)
         {
             Console.Write("Please enter temperature in celcius:");
             Console.WriteLine(wc.celciustofarenheit(Double.Parse(Console.ReadLine())));
         }
         else if (input == 2)
         {
             Console.Write("Please enter temperature in farenheit:");
             Console.WriteLine(wc.farenheittocelcius(Double.Parse(Console.ReadLine())));
         }
         else
         {
             break;
         }
     }
 }
        public async void GetWeatherLocationDetail()
        {
            var factory = new MockHttpClientFactory();
            var client  = new WeatherServiceClient(factory);

            var result = await client.GetWeatherLocationDetail(HonoluluWoeid);
        }
        public async void GetWeatherLocations()
        {
            var factory = new MockHttpClientFactory();
            var client  = new WeatherServiceClient(factory);

            var result = await client.GetWeatherLocations(Latitude, Longitude);
        }
Ejemplo n.º 5
0
        private static void Main()
        {
            Console.Title = "ExampleEpsilon.Client";
            Console.WriteLine("Press any key to start client.");
            Console.ReadKey();
            Console.WriteLine();

            const string serviceUrl = "http://*****:*****@"C:\SoapLog\Epsilon\Client";
            const bool     saveOriginalBinaryBody = false;
            const bool     useCustomHandler       = false;
            MessageVersion messageVersion         = MessageVersion.Soap11;

            var customBinding = new CustomBinding();

            customBinding.Elements.Add(new LoggingBindingElement(logPath, saveOriginalBinaryBody, useCustomHandler, messageVersion));
            customBinding.Elements.Add(new HttpTransportBindingElement());

            var serviceClient = new WeatherServiceClient(customBinding, address);

            var randomDataClient = new RandomDataClient(() => serviceClient);

            randomDataClient.StartThreads();

            Task.Delay(500).ContinueWith(_ => Process.Start("explorer.exe", logPath));

            Console.ReadLine();
        }
Ejemplo n.º 6
0
 void MainPage_Loaded(object sender, RoutedEventArgs e)
 {
     _client = new WeatherServiceClient(
         new System.ServiceModel.InstanceContext(this));
     _client.SubscribeCompleted   += _client_SubscribeCompleted;
     _client.UnSubscribeCompleted += _client_UnSubscribeCompleted;
 }
Ejemplo n.º 7
0
 void MainPage_Loaded(object sender, RoutedEventArgs e)
 {
     _client = new WeatherServiceClient(
         new System.ServiceModel.InstanceContext(this));
     _client.SubscribeCompleted += _client_SubscribeCompleted;
     _client.UnSubscribeCompleted += _client_UnSubscribeCompleted;
 }
Ejemplo n.º 8
0
        private static void Main()
        {
            Console.Title = "ExampleEpsilon.Client";
            Console.WriteLine("Press any key to start client.");
            Console.ReadKey();
            Console.WriteLine();

            const string serviceUrl = @"http://*****:*****@"C:\SoapLog\Epsilon\Client";
            string useCustomHandler = Boolean.FalseString;

            CustomBinding customBinding = new CustomBinding();

            customBinding.Elements.Add(new LoggingBindingElement(logPath, useCustomHandler));
            customBinding.Elements.Add(new HttpTransportBindingElement());

            var serviceClient = new WeatherServiceClient(customBinding, address);

            var randomDataClient = new RandomDataClient(serviceClient);

            randomDataClient.StartThreads();

            Console.ReadLine();
        }
Ejemplo n.º 9
0
        public async void GetWeatherLocationSearches(string data)
        {
            var handler        = HandlerMockFactory.GetHandlerMock(data);
            var weatherService = new WeatherServiceClient(handler);
            var result         = await weatherService.GetWeatherLocations(0d, 0d);

            result.Should().NotBeNull();
        }
Ejemplo n.º 10
0
    // Our client is scoped to the lifetime of the HttpApplication so
    // when the Application_End method is invoked, we should call Close on the client
    public void Application_End(object sender, EventArgs e)
    {
        WeatherServiceClient localClient = client;

        if (localClient != null && localClient.State == System.ServiceModel.CommunicationState.Opened)
        {
            localClient.Close();
        }
    }
        static void ShowWeatherData(WeatherServiceClient client, string[] localities)
        {
            WeatherData[] data = client.GetWeatherData(localities);

            foreach (WeatherData record in data)
            {
                Console.WriteLine("hi:{0}  lo:{1}  {2}", record.HighTemperature, record.LowTemperature, record.Locality);
            }
        }
Ejemplo n.º 12
0
 static void FtoC()
 {
     using (var client = new WeatherServiceClient())
     {
         var input  = GetInput();
         var output = client.FarenheitToCelcius(input);
         System.Console.WriteLine($"Farenheit: {input} - Celcius: {output}");
     }
 }
Ejemplo n.º 13
0
 static void CtoF()
 {
     using (var client = new WeatherServiceClient())
     {
         var input  = GetInput();
         var output = client.CelciusToFarenheit(input);
         System.Console.WriteLine($"Celcius: {input} - Farenheit: {output}");
     }
 }
Ejemplo n.º 14
0
        static void Main(string[] args)
        {
            IWeatherService weatherService = new WeatherServiceClient();

            Console.WriteLine("Simon says: {0}", weatherService.GetWeatherToday());
            WeatherData weatherData = weatherService.GetWeatherTomorrow();
            WeatherData weatherNext = weatherService.GetWeatherForDate(DateTime.Now.AddDays(1));

            Console.ReadLine();
        }
        public IEnumerable<WeatherData> It_Try_Get_Xml_Temperature()
        {
            var location = new GeoLocation() { Latitude = (float)33.481048, Longitude = (float)-86.704159 };
            var start = new DateTime(2004, 01, 01, 0, 0, 0);
            var end = new DateTime(2016, 09, 24, 0, 0, 0);

            var client = new WeatherServiceClient();
            var dataXml = client.GetRelativeHumidity(location.Latitude, location.Longitude, start, end);

            var data = new WeatherService().RelativeHumidity(location, start, end);

            Assert.IsNotNullOrEmpty(dataXml);
            return data;
        }
Ejemplo n.º 16
0
        private static void Main()
        {
            Console.Title = "ExampleTau.Client";
            Console.WriteLine("Press any key to start client.");
            Console.ReadKey();
            Console.WriteLine();

            var serviceClient    = new WeatherServiceClient();
            var randomDataClient = new RandomDataClient(serviceClient);

            randomDataClient.StartThreads();

            Console.ReadLine();
        }
Ejemplo n.º 17
0
        private static void InvokeWeatherForecastService()
        {
            var httpClient = new HttpClient();

            httpClient.DefaultRequestHeaders.Add("Authorization", jwt.GetToken());

            var client = new WeatherServiceClient(
                "https://localhost:44365/",
                httpClient);
            var forecast = client.WeatherForecastAsync().Result;

            foreach (var item in forecast)
            {
                Console.WriteLine($"{item.Summary}");
            }
        }
Ejemplo n.º 18
0
        static void Main(string[] args)
        {
            Console.WriteLine("Once the server starts, hit any key to call the weather service");
            Console.ReadLine();

            var client = new WeatherServiceClient("http://localhost:5000", new HttpClient());

            client.GetWeatherForecastAsync().Result.ToList().ForEach(x => Console.WriteLine($"{x.Summary} at {x.TemperatureF}"));

            var zipCode = "98052";

            client.GetWeatherForecastByZipCodeAsync(zipCode).Result.ToList().ForEach(x => Console.WriteLine($"The weather in {zipCode} is a {x.Summary} {x.TemperatureF}"));

            Console.WriteLine($"{Environment.NewLine}Called the weather service");
            Console.ReadLine();
        }
Ejemplo n.º 19
0
    protected void Page_Load(Object sender, EventArgs e)
    {
        // capture a reference to the cached client.  This reference will stay with this page for the
        // lifetime of the page.
        // we want to use this same instance of the client for calling BeginGetWeatherData and EndGetWeatherData
        // in order for any exceptions on the client to bubble up
        // if we didn't do this, there is a chance that the Global.Client instance could be
        // replaced and we may mask certain error conditions
        this.client = Global.Client;

        // This page is marked Async='true' so we need to
        // call the service asynchronously to get the weather data
        client.GetWeatherDataCompleted += new EventHandler <GetWeatherDataCompletedEventArgs>(client_GetWeatherDataCompleted);
        string[] localities = { "Los Angeles", "Rio de Janeiro", "New York", "London", "Paris", "Rome", "Cairo", "Beijing" };
        client.GetWeatherDataAsync(localities);
    }
Ejemplo n.º 20
0
    protected void Page_Load(Object sender, EventArgs e)
    {
        // capture a reference to the cached client.  This reference will stay with this page for the
        // lifetime of the page.
        // we want to use this same instance of the client for calling BeginGetWeatherData and EndGetWeatherData
        // in order for any exceptions on the client to bubble up
        // if we didn't do this, there is a chance that the Global.Client instance could be
        // replaced and we may mask certain error conditions
        this.client = Global.Client;

        // This page is marked Async='true' so we need to 
        // call the service asynchronously to get the weather data
        client.GetWeatherDataCompleted += new EventHandler<GetWeatherDataCompletedEventArgs>(client_GetWeatherDataCompleted);
        string[] localities = { "Los Angeles", "Rio de Janeiro", "New York", "London", "Paris", "Rome", "Cairo", "Beijing" };
        client.GetWeatherDataAsync(localities);
    }
        static void Main(string[] args)
        {
            string[] localities = { "Los Angeles", "Rio de Janeiro", "New York", "London" }; //, "Paris", "Rome", "Cairo", "Beijing" };

            Console.WriteLine("First Call - without Xsl Transformation\r\nTemperature in Farenheit : ");
            _client = new WeatherServiceClient();
            ShowWeatherData(_client, localities);

            Console.WriteLine("\r\n=====================\r\n");
            Console.WriteLine("Second Call - Xsl Transformation\r\nTemperature in Celsius : ");

            _client = new WeatherServiceClient();
            _client.Endpoint.Behaviors.Add(new XslTransformBehavior("ConvertToCelsius.xsl"));
            ShowWeatherData(_client, localities);

            Console.WriteLine("Done");
        }
        public IEnumerable <WeatherData> It_Try_Get_Xml_Temperature()
        {
            var location = new GeoLocation()
            {
                Latitude = (float)33.481048, Longitude = (float)-86.704159
            };
            var start = new DateTime(2004, 01, 01, 0, 0, 0);
            var end   = new DateTime(2016, 09, 24, 0, 0, 0);

            var client  = new WeatherServiceClient();
            var dataXml = client.GetRelativeHumidity(location.Latitude, location.Longitude, start, end);

            var data = new WeatherService().RelativeHumidity(location, start, end);

            Assert.IsNotNullOrEmpty(dataXml);
            return(data);
        }
Ejemplo n.º 23
0
        private static void Main()
        {
            Console.Title = "ExampleBeta.Client";
            Console.WriteLine("Press any key to start client.");
            Console.ReadKey();
            Console.WriteLine();

            // if no custom handling - it's ok to reuse client class object

            var serviceClient    = new WeatherServiceClient();
            var randomDataClient = new RandomDataClient(() => serviceClient);

            randomDataClient.StartThreads();

            Task.Delay(500).ContinueWith(_ => Process.Start("explorer.exe", @"C:\SoapLog\Beta"));

            Console.ReadLine();
        }
Ejemplo n.º 24
0
        private static void Main()
        {
            Console.Title = "ExampleDelta.Client";
            Console.WriteLine("Press any key to start client.");
            Console.ReadKey();
            Console.WriteLine();

            var serviceClient = new WeatherServiceClient();

            serviceClient.ClientCredentials.UserName.UserName = "******";
            serviceClient.ClientCredentials.UserName.Password = "******";

            var randomDataClient = new RandomDataClient(serviceClient);

            randomDataClient.StartThreads();

            Console.ReadLine();
        }
Ejemplo n.º 25
0
        public void GetDataFromService(string urlCity, bool isCities)
        {
            var client = new WeatherServiceClient("BasicHttpBinding_IWeatherService");

            if (client.State == CommunicationState.Created)
            {
                if (isCities)
                {
                    this._cities = client.GetCities();
                }
                this._meteo = client.GetWeather(urlCity);
                //в случае отказа сервера в получении текущей даты
                if (this._meteo.CurrentDay == null)
                {
                    this._meteo.CurrentDay = this._meteo.Days.FirstOrDefault(day => day.Day.Contains(DateTime.Now.ToString("dd MMMM"))) ?? this._meteo.Days.FirstOrDefault(day => day.Day.Contains(DateTime.Now.AddDays(1).ToString("dd MMMM")));
                }
            }
        }
        public void GetWeatherResultAsync_Success()
        {
            // arrange
            Mock <IWeatherServiceReadersFactory> weatherServiceReadersFactory = new Mock <IWeatherServiceReadersFactory>();
            Mock <IWeatherServiceReader>         bbccWeatherServiceReader     = new Mock <IWeatherServiceReader>();

            bbccWeatherServiceReader.Setup(x => x.WeatherReaderAsync(It.IsAny <HttpClient>())).Returns(async() =>
            {
                await Task.Yield();
                return(new WeatherResultInCelsiusAndKph
                {
                    Temperature = 20,
                    WindSpeed = 16
                });
            });

            Mock <IWeatherServiceReader> accuWeatherServiceReader = new Mock <IWeatherServiceReader>();

            accuWeatherServiceReader.Setup(x => x.WeatherReaderAsync(It.IsAny <HttpClient>())).Returns(async() =>
            {
                await Task.Yield();
                return(new WeatherResultInCelsiusAndKph
                {
                    Temperature = 10,
                    WindSpeed = 8
                });
            });

            weatherServiceReadersFactory.Setup(x => x.CreateBbcWeatherServiceReader(bbcweatherserviceUrl)).Returns(bbccWeatherServiceReader.Object);

            weatherServiceReadersFactory.Setup(x => x.CreateAccuWeatherServiceReader(accweatherserviceUrl)).Returns(accuWeatherServiceReader.Object);

            // act
            IWeatherServiceClient        weatherServiceClient = new WeatherServiceClient(weatherServiceReadersFactory.Object);
            WeatherResultInCelsiusAndKph weatherResult        = null;

            Task.Run(async() =>
            {
                weatherResult = await weatherServiceClient.GetWeatherResultAsync(new HttpClient(), "london");
            }).Wait();

            // assert
            Assert.IsTrue(weatherResult.Temperature == 15 && weatherResult.WindSpeed == 12);
        }
Ejemplo n.º 27
0
        private WeatherDataJson GetDataFromWCF(ServiceProvider.IServiceProvider service)
        {
            WeatherDataJson weatherData = new WeatherDataJson();
            string          data        = string.Empty;

            var end_adress = new EndpointAddress("http://localhost:8733/Design_Time_Addresses/WeatherWCF/WeatherService/");

            using (WeatherServiceClient proxy = new WeatherServiceClient(new BasicHttpBinding(), end_adress))
            {
                data = proxy.GetData(service.ServiceName(CityName));
            }

            if (!string.IsNullOrEmpty(data))
            {
                weatherData = ConvertHelper.ConvertFromJSON(data);
            }

            return(weatherData);
        }
Ejemplo n.º 28
0
        public async Task ShouldReturnForecastWeCalled()
        {
            // Assign
            var content           = "{}";
            var httpClientWrapper = new Mock <IHttpClientWrapper>();

            httpClientWrapper.Setup(w => w.GetAsync(It.IsAny <string>())).Returns(Task.FromResult(content));
            var parser = new Mock <IReponseParser>();

            parser.Setup(p => p.GetNextTemperature(It.IsAny <string>())).Returns(297.89M);
            var weatherServiceClient = new WeatherServiceClient(httpClientWrapper.Object, parser.Object);
            // Act
            var result = await weatherServiceClient.FetchForecast();

            // Assert
            var expected = 25;

            Assert.AreEqual(expected, result.DegreesForToday);
        }
Ejemplo n.º 29
0
        private static void Main()
        {
            Console.Title = "ExampleDelta.Client";
            Console.WriteLine("Press any key to start client.");
            Console.ReadKey();
            Console.WriteLine();

            var serviceClient = new WeatherServiceClient();

            serviceClient.ClientCredentials.UserName.UserName = "******";
            serviceClient.ClientCredentials.UserName.Password = "******";

            var randomDataClient = new RandomDataClient(() => serviceClient);

            randomDataClient.StartThreads();

            Task.Delay(500).ContinueWith(_ => Process.Start("explorer.exe", @"C:\SoapLog\Delta"));

            Console.ReadLine();
        }
Ejemplo n.º 30
0
        static void Main(string[] args)
        {
            WeatherServiceClient client =
                new WeatherServiceClient();

            Console.WriteLine("Välkommen till vädertjänsten!");
            Console.Write("Vilken plats vill du veta vädret på? ");
            string      location = Console.ReadLine();
            WeatherData data     = client.GetWeather(location);

            if (data == null)
            {
                Console.WriteLine("Kunde inte hitta något väder");
            }
            else
            {
                Console.WriteLine("Vädret på " + data.Location
                                  + " är " + data.RiskOfRain + "% regnrisk och "
                                  + data.WindStrength + " m/s vind.");
            }
            Console.ReadKey();
        }
Ejemplo n.º 31
0
        private void ShowForecast(int days, int zipCode)
        {
            using (WeatherServiceClient relyingParty = new WeatherServiceClient())
            {
                WeatherInfo weatherInfo = null;

                try
                {
                    this.Cursor           = Cursors.WaitCursor;
                    this.sourceLabel.Text = "Loading...";

                    if (days == 3)
                    {
                        weatherInfo = relyingParty.GetThreeDaysForecast(zipCode);
                    }
                    else if (days == 10)
                    {
                        weatherInfo = relyingParty.GetTenDaysForecast(zipCode);
                    }

                    this.DisplayForecast(weatherInfo.Forecast);
                    this.sourceLabel.Text = string.Format(
                        CultureInfo.InvariantCulture,
                        "Source: {0}",
                        weatherInfo.Observatory);
                }
                catch (MessageSecurityException ex)
                {
                    this.sourceLabel.Text = string.Empty;
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    relyingParty.Abort();
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }
            }
        }
Ejemplo n.º 32
0
        public void GetWeather()
        {
            if (!_cache.Contains(City))
            {
                var weatherService = new WeatherServiceClient();
                ResultForecust = weatherService.GetWeather(City);
                var policy = new CacheItemPolicy {
                    AbsoluteExpiration = DateTimeOffset.MaxValue
                };
                _cache.Add(City, ResultForecust, policy);
            }
            else
            {
                var cacheItem = (WeatherForecust)_cache.GetCacheItem(City, null).Value;

                if (cacheItem.CurrentWeather[0].Data.From.AddHours(3) > DateTime.Now)
                {
                    ResultForecust = cacheItem;
                }
            }
            CurrenWeather   = CollectWeatherData(ResultForecust.CurrentWeather);
            WeatherForeCust = CollectWeatherData(ResultForecust.Forecast);
        }
Ejemplo n.º 33
0
 public WeatherService()
 {
     _weatherServiceClient = new WeatherServiceClient();
 }
Ejemplo n.º 34
0
        public WeatherPage()
        {
            InitializeComponent();

            client =
                new WeatherServiceClient(
                    GetBinding(),
                    GetEndpointAddress("Weather"));

            client.GetMyWeatherLocationsDetailsCompleted +=
                (o1, e1) =>
            {
                HideProgress();

                LoadingMessage.Visibility = Visibility.Collapsed;

                if (e1.Error != null)
                {
                    if (e1.Error.GetType() == typeof(FaultException <AuthenticationFault>))
                    {
                        GetAuthenticationToken(
                            new Action(
                                () =>
                        {
                            client.GetMyWeatherLocationsDetailsAsync(Settings.CachedAuthenticationToken);
                        }
                                ));
                    }
                    else
                    {
                        MessageBox.Show(e1.Error.Message);
                    }

                    return;
                }

                BitmapImage bi = null;

                weatherViewModel.Clear();
                foreach (var w in e1.Result)
                {
                    ObservableCollection <Weather> forecast = new ObservableCollection <Weather>();
                    if (w.Forecast != null)
                    {
                        foreach (var f in w.Forecast)
                        {
                            bi = new BitmapImage();
                            bi.SetSource(new MemoryStream(f.Icon));

                            forecast.Add(
                                new Weather()
                            {
                                Condition       = f.Condition,
                                Date            = f.Date.DayOfWeek.ToString(),
                                Forecast        = null,
                                HighTemperature = String.Format(CultureInfo.InvariantCulture, "High: {0}", f.HighTemperature),
                                Image           = bi,
                                Location        = null,
                                LowTemperature  = String.Format(CultureInfo.InvariantCulture, "Low: {0}", f.LowTemperature),
                                Temperature     = null,
                            });
                        }
                    }

                    bi = new BitmapImage();
                    bi.SetSource(new MemoryStream(w.Icon));

                    weatherViewModel.Add(
                        new Weather()
                    {
                        Condition       = w.Condition,
                        Date            = null,
                        Forecast        = forecast,
                        HighTemperature = null,
                        Image           = bi,
                        Location        = w.Location,
                        LowTemperature  = null,
                        Temperature     = w.Temperature,
                    });
                }
            };
            // this is used for the gps function
            client.GetWeatherCompleted +=
                (o1, e1) =>
            {
                if (e1.Error != null)
                {
                    // TODO:
                    return;
                }

                BitmapImage bi = null;

                if (weatherViewModel.FirstOrDefault(w => w.Location == e1.Result.Location) == null)
                {
                    ObservableCollection <Weather> forecast = new ObservableCollection <Weather>();
                    if (e1.Result.Forecast != null)
                    {
                        foreach (var f in e1.Result.Forecast)
                        {
                            bi = new BitmapImage();
                            bi.SetSource(new MemoryStream(f.Icon));
                            forecast.Add(
                                new Weather()
                            {
                                Condition       = f.Condition,
                                Date            = f.Date.DayOfWeek.ToString(),
                                Forecast        = null,
                                HighTemperature = String.Format(CultureInfo.InvariantCulture, "High: {0}", f.HighTemperature),
                                Image           = bi,
                                Location        = null,
                                LowTemperature  = String.Format(CultureInfo.InvariantCulture, "Low: {0}", f.LowTemperature),
                                Temperature     = null,
                            });
                        }
                    }

                    bi = new BitmapImage();
                    bi.SetSource(new MemoryStream(e1.Result.Icon));
                    weatherViewModel.Add(
                        new Weather()
                    {
                        Condition       = String.Format(CultureInfo.InvariantCulture, "{0} degrees and {1}", e1.Result.Temperature, e1.Result.Condition),
                        Date            = null,
                        Forecast        = forecast,
                        HighTemperature = null,
                        Image           = bi,
                        Location        = e1.Result.Location,
                        LowTemperature  = null,
                        Temperature     = null,
                    });
                }

                WeatherList.SelectedIndex = WeatherList.Items.IndexOf(WeatherList.Items.FirstOrDefault(w => (w as Weather).Location == e1.Result.Location));

                HideProgress();
            };
            client.AddWeatherLocationCompleted +=
                (o1, e1) =>
            {
                if (e1.Error != null)
                {
                    if (e1.Error.GetType() == typeof(FaultException <AuthenticationFault>))
                    {
                        // TODO:
                        //GetAuthenticationToken(
                        //    new Action(
                        //        () =>
                        //        {
                        //            client.GetMyStockDataAsync(Settings.CachedAuthenticationToken);
                        //        }
                        //    ));
                    }
                    else
                    {
                        MessageBox.Show(e1.Error.Message);
                    }

                    HideProgress();

                    return;
                }

                if (!e1.Result)
                {
                    MessageBox.Show("Error adding weather location");
                }
                else
                {
                    client.GetMyWeatherLocationsDetailsAsync(Settings.CachedAuthenticationToken);
                }
            };
            client.RemoveWeatherLocationCompleted +=
                (o1, e1) =>
            {
                if (e1.Error != null)
                {
                    if (e1.Error.GetType() == typeof(FaultException <AuthenticationFault>))
                    {
                        // TODO:
                        //GetAuthenticationToken(
                        //    new Action(
                        //        () =>
                        //        {
                        //            client.GetMyStockDataAsync(Settings.CachedAuthenticationToken);
                        //        }
                        //    ));
                    }
                    else
                    {
                        MessageBox.Show(e1.Error.Message);
                    }

                    HideProgress();

                    return;
                }

                if (!e1.Result)
                {
                    MessageBox.Show("Error removing weather location");
                }
                else
                {
                    client.GetMyWeatherLocationsDetailsAsync(Settings.CachedAuthenticationToken);
                }
            };



            watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default);
            watcher.StatusChanged +=
                (o1, e1) =>
            {
            };
            watcher.PositionChanged +=
                (o1, e1) =>
            {
                ReverseGeocodeRequest request =
                    new ReverseGeocodeRequest()
                {
                    Credentials =
                        new Credentials()
                    {
                        ApplicationId = "Arz9raeGhoGWF5U5hv0Py-wnLL1ZMa82OF5BrFlSKExWfHzhlOaQ8gwBJldxi3Hg"
                    },
                    Location =
                        new Location()
                    {
                        Latitude  = e1.Position.Location.Latitude,
                        Longitude = e1.Position.Location.Longitude,
                    }
                };
                geoCodeClient.ReverseGeocodeAsync(request, e1.Position.Location);

                watcher.Stop();
            };


            geoCodeClient =
                new GeocodeServiceClient(
                    GetBinding(),
                    new EndpointAddress(new Uri("http://dev.virtualearth.net/webservices/v1/geocodeservice/GeocodeService.svc")));
            geoCodeClient.ReverseGeocodeCompleted +=
                (o1, e1) =>
            {
                if (e1.Error != null)
                {
                    HideProgress();
                    MessageBox.Show("Error resolving your location");
                }
                else
                {
                    var address = e1.Result.Results.FirstOrDefault().Address;
                    client.GetWeatherAsync(Settings.CachedAuthenticationToken, address.Locality + ", " + address.AdminDistrict);
                }
            };
            geoCodeClient.GeocodeCompleted +=
                (o1, e1) =>
            {
                if (e1.Error != null)
                {
                    HideProgress();
                    MessageBox.Show("Error resolving your location");
                }
                else
                {
                    ListBoxSearchedLocations.ItemsSource = e1.Result.Results;
                }
            };


            WeatherList.ItemsSource             = weatherViewModel;
            weatherViewModel.CollectionChanged +=
                (o, e) =>
            {
                if (weatherViewModel.Count > 0)
                {
                    NotLoadedSection.Visibility = NoItemsMessage.Visibility = Visibility.Collapsed;
                }

                if (weatherViewModel.Count == 0)
                {
                    LoadingMessage.Visibility = Visibility.Collapsed;
                    NoItemsMessage.Visibility = Visibility.Visible;
                }
            };
        }
 public void Initialize(WeatherServiceClient proxy)
 {
     this.proxy = proxy;
 }