public GLOutput(GLOutput glOutput, GeocodeComponents geocode) { Login = glOutput.Login; GitLocation = glOutput.GitLocation; Locality = geocode.Locality; AdminAreaLevel1 = geocode.AdminAreaLevel1; AdminAreaLevel2 = geocode.AdminAreaLevel2; Country = geocode.Country; }
public async Task <GeocodeComponents> LookupGeocode(string query) { // build request var request = new RestRequest("geocode/json"); request.AddQueryParameter("key", _apiKey); request.AddQueryParameter("address", query); // get results var response = await RestClient.ExecuteGetTaskAsync(request); using (var jsonReader = new MongoDB.Bson.IO.JsonReader(response.Content)) { // parse to bson var serializer = new BsonDocumentSerializer(); var bsonDocument = serializer.Deserialize(BsonDeserializationContext.CreateRoot(jsonReader)); // cast to geocode components var geocode = new GeocodeComponents(bsonDocument); return(geocode); } }