本文整理匯總了C#中System.Language.ToValue方法的典型用法代碼示例。如果您正苦於以下問題:C# Language.ToValue方法的具體用法?C# Language.ToValue怎麽用?C# Language.ToValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Language
的用法示例。
在下文中一共展示了Language.ToValue方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetTimeMachineWeatherAsync
/// <summary>
/// Asynchronously retrieves weather data for a particular latitude and longitude, on
/// a given day.
/// <para>
/// Only conditions for the day are given (i.e. the time is ignored, and taken to be the
/// current time).
/// </para>
/// <para>
/// Allows specification of units of measurement, language used, extended hourly forecasts,
/// and exclusion of data blocks.
/// </para>
/// </summary>
/// <param name="latitude">
/// The latitude to retrieve data for.
/// </param>
/// <param name="longitude">
/// The longitude to retrieve data for.
/// </param>
/// <param name="date">
/// The date to retrieve data for.
/// </param>
/// <param name="unit">
/// The units of measurement to use.
/// </param>
/// <param name="extends">
/// The type of forecast to retrieve extended results for. Currently limited to hourly blocks.
/// </param>
/// <param name="excludes">
/// Any blocks that should be excluded from the request.
/// </param>
/// <param name="language">
/// The language to use for summaries.
/// </param>
/// <returns>
/// A <see cref="Task"/> for a <see cref="Forecast"/> with the requested data, or null if the data was corrupted.
/// </returns>
public async Task<Forecast> GetTimeMachineWeatherAsync(
double latitude,
double longitude,
DateTimeOffset date,
Unit unit,
IList<Extend> extends,
IList<Exclude> excludes,
Language language)
{
this.ThrowExceptionIfApiKeyInvalid();
var unitValue = unit.ToValue();
var extendList = string.Join(",", extends.Select(x => x.ToValue()));
var excludeList = string.Join(",", excludes.Select(x => x.ToValue()));
var languageValue = language.ToValue();
var unixTime = date.ToUnixTime();
var requestUrl = string.Format(
CultureInfo.InvariantCulture,
SpecificTimeConditionsUrl,
this.apiKey,
latitude,
longitude,
unixTime,
unitValue,
extendList,
excludeList,
languageValue);
return await this.GetForecastFromUrl(requestUrl);
}