コード例 #1
0
 /// <summary>
 /// Handles the address search event of the client control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.Net.OpenReadCompletedEventArgs"/> instance containing the event data.</param>
 private void clientFindAddress(object sender, OpenReadCompletedEventArgs e)
 {
     ////If no Error
     if (e.Error == null)
     {
         try
         {
             ////Getting result stream
             var s = e.Result;
             var _jsonDeserializer = new JsonSerializer();
             var _jsonReader       = new JsonTextReader(new StreamReader(s));
             var resp = (KladrResponse)_jsonDeserializer.Deserialize(_jsonReader, typeof(KladrResponse));
             if (_apiCall != null)
             {
                 resp.InfoMessage = "OK";
                 _apiCall.Invoke(resp);
             }
         }
         catch (SerializationException ex)
         {
             ////Calling proper callback and setting error data.
             invokeException(ex.InnerException, ex.Message);
         }
         finally
         {
             if (e.Result != null)
             {
                 e.Result.Close();
             }
         }
     }
     else
     {
         ////Calling proper callback and setting error data.
         invokeException(e.Error, e.Error.Message);
     }
 }