/// <summary> /// Sends the message. /// </summary> /// <param name="address">The address.</param> /// <returns>Coordinates of address</returns> /// <exception cref="System.Exception">Error: + ex.Message</exception> Coordinates IGeolocationProvider.GetCoordinates(AddressContainer address) { string addressString = string.Empty; if(!string.IsNullOrEmpty(address.AddressLine1)) { addressString += address.AddressLine1.Replace(" ", "+") + ",+"; } if (!string.IsNullOrEmpty(address.AddressLine2)) { addressString += address.AddressLine2.Replace(" ", "+") + ",+"; } addressString += address.City.Replace(" ", "+") + ",+"; addressString += address.Country.Replace(" ", "+"); string key = ConfigurationManager.AppSettings["GoogleEndpointAuthorizationKey"]; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(string.Format(ConfigurationManager.AppSettings["GeolocationEndpoint"], addressString, "&", key)); request.Method = "GET"; request.ContentType = "application/json"; try { using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { using (Stream responseStream = response.GetResponseStream()) { DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(GoogleApiGeocodeContainer)); GoogleApiGeocodeContainer result = (GoogleApiGeocodeContainer) serializer.ReadObject(responseStream); if (result.Status == "OK") { Coordinates coordinates = new Coordinates(); coordinates.Latitude = result.Results[0].Geometry.Location.Latitude; coordinates.Longitude = result.Results[0].Geometry.Location.Longitude; return coordinates; } else { return new Coordinates(); } } } } catch (Exception ex) { throw new Exception("Error: " + ex.Message); } }
public void RoundTripSpecialCharsTest() { AddressContainer obj = new AddressContainer() { AddressInst = new Address() { Street = @"He said, ""Kewl, isn't it?"" ", City = @"1 != 2, {3 + 4}", State = @"http:\\cool.com\index.html" } }; AddressContainer objAfterRoundTrip = RoundTrip(obj) as AddressContainer; Assert.IsNotNull(objAfterRoundTrip); Assert.IsNotNull(objAfterRoundTrip.AddressInst); Assert.AreEqual(objAfterRoundTrip.AddressInst.Street, obj.AddressInst.Street); Assert.AreEqual(objAfterRoundTrip.AddressInst.State, obj.AddressInst.State); Assert.AreEqual(objAfterRoundTrip.AddressInst.City, obj.AddressInst.City); }
void ReleaseDesignerOutlets() { if (ContentView != null) { ContentView.Dispose(); ContentView = null; } if (AddressContainer != null) { AddressContainer.Dispose(); AddressContainer = null; } if (AddressHeightConstraint != null) { AddressHeightConstraint.Dispose(); AddressHeightConstraint = null; } if (AddressLabel != null) { AddressLabel.Dispose(); AddressLabel = null; } if (CoverView != null) { CoverView.Dispose(); CoverView = null; } if (MapView != null) { MapView.Dispose(); MapView = null; } }
private static DataSet GetUserProfile() { DataSet returnData = new DataSet(); DataTable table = new DataTable("InfoTable"); table.Columns.Add("Name"); table.Columns.Add("PhoneNumber"); table.Columns.Add("IsVerified"); table.Columns.Add("ContactPref"); table.Columns.Add("EmailAddress"); table.Columns.Add("Address"); table.Columns.Add("IsAgent"); table.Columns.Add("IsManager"); table.Columns.Add("LandingPage"); table.Columns.Add("PushNotificationsUri"); table.Columns.Add("AgentRating"); table.Columns.Add("AgentRatingCount"); table.Columns.Add("UserRating"); table.Columns.Add("UserRatingCount"); table.Columns.Add("Tags"); table.Columns.Add("AreaofService"); table.Columns.Add("FavoriteAgents"); DataRow row1 = table.NewRow(); row1["Name"] = "Rittu Jain"; row1["PhoneNumber"] = "+919867856543"; row1["IsVerified"] = true; row1["ContactPref"] = "Chat" + Constants.QuerySeparator + "Email"; ; row1["EmailAddress"] = "*****@*****.**"; AddressContainer addressContainer = new AddressContainer(); addressContainer.AddressLine1 = "1000 Having St"; addressContainer.City = "Hasting"; addressContainer.PostalCode = "40001"; addressContainer.Country = "USA"; row1["Address"] = new JavaScriptSerializer().Serialize(addressContainer); row1["IsAgent"] = true; row1["IsManager"] = true; row1["LandingPage"] = "Agent"; row1["PushNotificationsUri"] = "Junk"; row1["AgentRating"] = 4.5; row1["AgentRatingCount"] = 56; row1["UserRating"] = 4.5; row1["UserRatingCount"] = 56; row1["Tags"] = "PartyPlaning|$|CabService|$|Balloons"; row1["AreaOfService"] = 20.0; row1["FavoriteAgents"] = null; table.Rows.Add(row1); returnData.Tables.Add(table); return returnData; }