コード例 #1
0
        /// <summary>
        /// Hourly forecast by OpenWeatherMap! Hourly forecast for 4 days, with 96 timestamps and higher geographic accuracy.
        /// </summary>
        /// <param name="city"></param>
        /// <param name="units"></param>
        /// <returns></returns>
        public async Task <WeatherHistoryRoot> GetForecast(string city, Enums.Units units = Enums.Units.Imperial)
        {
            try
            {
                var request  = RestService.For <IWeatherService>(_baseUrl);
                var response = await request.GetForecast(city).ConfigureAwait(false);

                return(response);
            }
            catch (System.Exception e)
            {
                throw;
            }
        }
コード例 #2
0
        /// <summary>
        /// Access current weather data for any location on Earth including over 200,000 cities! We collect and process weather data from different sources such as global and local weather models, satellites, radars and vast network of weather stations.
        /// </summary>
        /// <param name="city"></param>
        /// <param name="units"></param>
        /// <returns></returns>
        public async Task <WeatherRoot> GetWeather(string city, string apiKey, Enums.Units units = Enums.Units.Imperial)
        {
            if (string.IsNullOrEmpty(city))
            {
                return(null);
            }

            try
            {
                var request  = RestService.For <IWeatherService>(_baseUrl);
                var response = await request.GetWeather(city, apiKey).ConfigureAwait(false);

                return(response);
            }
            catch (System.Exception e)
            {
                throw;
            }
        }
コード例 #3
0
 /// <summary>
 /// Expands the specified range or selection. Returns the number of characters added to the range or selection.
 /// </summary>
 /// <param name="unit">The unit by which to expand the range. Can be one of the following Units constants: Character, Word, Sentence, Paragraph, Section, Story, Cell, Column, Row, or Table.</param>
 /// <returns></returns>
 public long Expand(Enums.Units unit)
 {
     return(Convert.ToInt64(InternalObject.GetType().InvokeMember("Expand", System.Reflection.BindingFlags.InvokeMethod, null, InternalObject, new object[] { unit })));
 }
コード例 #4
0
        /// <summary>
        /// Access current weather data for any location on Earth including over 200,000 cities! We collect and process weather data from different sources such as global and local weather models, satellites, radars and vast network of weather stations.
        /// </summary>
        /// <param name="latitude"></param>
        /// <param name="longitude"></param>
        /// <param name="units"></param>
        /// <returns></returns>
        public async Task <WeatherRoot> GetWeather(double latitude, double longitude, string apiKey, Enums.Units units = Enums.Units.Imperial)
        {
            try
            {
                var request  = RestService.For <IWeatherService>(_baseUrl);
                var response = await request.GetWeather(latitude, longitude, apiKey).ConfigureAwait(false);

                return(response);
            }
            catch (System.Exception e)
            {
                throw;
            }
        }
コード例 #5
0
        /// <summary>
        /// The One Call API provides the following weather data for any geographical coordinates:
        /// Current weather
        /// Minute forecast for 1 hour
        /// Hourly forecast for 48 hours
        /// Daily forecast for 7 days
        /// Government weather alerts
        /// Historical weather data for the previous 5 days
        /// </summary>
        /// <param name="latitude"></param>
        /// <param name="longitude"></param>
        /// <param name="units"></param>
        /// <returns></returns>
        public async Task <WeatherHistoryRoot> GetOneCall(double latitude, double longitude, string apiKey, Enums.Units units = Enums.Units.Imperial)
        {
            try
            {
                var request  = RestService.For <IWeatherService>(_baseUrl);
                var response = await request.GetOneCall(latitude, longitude, apiKey).ConfigureAwait(false);

                return(response);
            }
            catch (ValidationApiException validationException)
            {
                // handle validation here by using validationException.Content,
                // which is type of ProblemDetails according to RFC 7807

                // If the response contains additional properties on the problem details,
                // they will be added to the validationException.Content.Extensions collection.
                throw;
            }
            catch (ApiException exception)
            {
                // other exception handling
                throw;
            }
            catch (System.Exception e)
            {
                throw;
            }
        }
コード例 #6
0
ファイル: GoogleMapService.cs プロジェクト: tcerdaj/PoolGuy
        /// <summary>
        /// Get Google map direcctions based in stops with route optimization
        /// Caution: Requests using waypoint optimization are billed at a higher rate. Learn more about how Google Maps Platform products are billed.
        /// </summary>
        /// <param name="startPoint">Start point can be the brach location or techitial fisical address or enter by the user</param>
        /// <param name="endPoint">End point can be the brach location or techitial fisical address or enter by the user</param>
        /// <param name="stops">Represent the tech stops in the route is reparated by | </param>
        /// <param name="avoid">tolls|highways|ferries|</param>
        /// <param name="apiKey"></param>
        /// <param name="units">Use imperial or metric, imperial by default</param>
        /// <returns>Direction</returns>
        public async Task <Direction> GetOptimizeDirections(string startPoint, string endPoint, string stops, string avoid, string apiKey, Enums.Units units = Enums.Units.Imperial)
        {
            try
            {
                var request  = RestService.For <IGoogleMapService>(_baseUrl);
                var response = await request
                               .GetOptimizeDirections(startPoint, endPoint, stops, avoid, apiKey)
                               .ConfigureAwait(false);

                return(response);
            }
            catch (Exception ex)
            {
                throw;
            }
        }