本文整理汇总了C#中Units.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Units.ToString方法的具体用法?C# Units.ToString怎么用?C# Units.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Units
的用法示例。
在下文中一共展示了Units.ToString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetForecast
public async Task<WeatherForecastRoot> GetForecast(int id, Units units = Units.Imperial)
{
using (var client = new HttpClient())
{
var url = string.Format(ForecaseUri, id, units.ToString().ToLower());
var json = await client.GetStringAsync(url);
if (string.IsNullOrWhiteSpace(json))
return null;
return DeserializeObject<WeatherForecastRoot>(json);
}
}
示例2: GetWeather
public async Task<WeatherRoot> GetWeather(string city, Units units = Units.Imperial)
{
using (var client = new HttpClient())
{
var url = string.Format(WeatherCityUri, city, units.ToString().ToLower());
var json = await client.GetStringAsync(url);
if (string.IsNullOrWhiteSpace(json))
return null;
return JsonConvert.DeserializeObject<WeatherRoot>(json);
}
}
示例3: GetWeather
public async Task<WeatherRoot> GetWeather(double latitude, double longitude, Units units = Units.Imperial)
{
using (var client = new HttpClient())
{
var url = string.Format(WeatherCoordinatesUri, latitude, longitude, units.ToString().ToLower());
var json = await client.GetStringAsync(url);
if (string.IsNullOrWhiteSpace(json))
return null;
return DeserializeObject<WeatherRoot>(json);
}
}
示例4: Counter
/// <summary>
/// A counter is a simple incrementing and decrementing 64-bit integer. Ex number of active requests.
/// </summary>
/// <param name="name">Name of the metric. Must be unique across all counters in this context.</param>
/// <param name="unit">Description of what the is being measured ( Unit.Requests , Unit.Items etc ) .</param>
/// <param name="tag">Optional tag that can be associated with the metric.</param>
/// <returns>Reference to the metric</returns>
public ICounter Counter(string name, Units unit, string tag = null)
{
return new Counter(_context.Counter(name, unit.ToString(), tag));
}
示例5: Gauge
/// <summary>
/// A gauge is the simplest metric type. It just returns a value. This metric is suitable for instantaneous values.
/// </summary>
/// <param name="name">Name of this gauge metric. Must be unique across all gauges in this context.</param>
/// <param name="valueProvider">Function that returns the value for the gauge.</param>
/// <param name="unit">Description of want the value represents ( Unit.Requests , Unit.Items etc ) .</param>
/// <param name="tag">Optional tag that can be associated with the metric.</param>
public void Gauge(string name, Func<double> valueProvider, Units unit, string tag = null)
{
_context.Gauge(name, valueProvider, unit.ToString(), tag);
}
示例6: Timer
/// <summary>
/// A timer is basically a histogram of the duration of a type of event and a meter of the rate of its occurrence.
/// </summary>
/// <param name="name">Name of the metric. Must be unique across all timers in this context.</param>
/// <param name="unit">Description of what the is being measured ( Unit.Requests , Unit.Items etc ) .</param>
/// <param name="samplingType">Type of the sampling to use (see SamplingType for details ).</param>
/// <param name="rateUnit">Time unit for rates reporting. Defaults to Second ( occurrences / second ).</param>
/// <param name="durationUnit">Time unit for reporting durations. Defaults to Milliseconds. </param>
/// <param name="tag">Optional tag that can be associated with the metric.</param>
/// <returns>Reference to the metric</returns>
public ITimer Timer(string name, Units unit, SamplingTypes samplingType = SamplingTypes.FavorRecent, TimeUnits rateUnit = TimeUnits.Seconds, TimeUnits durationUnit = TimeUnits.Milliseconds, string tag = null)
{
return new Timer(_context.Timer(name, unit.ToString(), (SamplingType)samplingType, (TimeUnit)rateUnit, (TimeUnit)durationUnit, tag));
}
示例7: Histogram
/// <summary>
/// A Histogram measures the distribution of values in a stream of data: e.g., the number of results returned by a search.
/// </summary>
/// <param name="name">Name of the metric. Must be unique across all histograms in this context.</param>
/// <param name="unit">Description of what the is being measured ( Unit.Requests , Unit.Items etc ) .</param>
/// <param name="samplingType">Type of the sampling to use (see SamplingType for details ).</param>
/// <param name="tag">Optional tag that can be associated with the metric.</param>
/// <returns>Reference to the metric</returns>
public IHistogram Histogram(string name, Units unit, SamplingTypes samplingType = SamplingTypes.FavorRecent, string tag = null)
{
return new Histogram(_context.Histogram(name, unit.ToString(), (SamplingType)samplingType, tag));
}
示例8: Meter
/// <summary>
/// A meter measures the rate at which a set of events occur, in a few different ways.
/// This metric is suitable for keeping a record of now often something happens ( error, request etc ).
/// </summary>
/// <remarks>
/// The mean rate is the average rate of events. It’s generally useful for trivia,
/// but as it represents the total rate for your application’s entire lifetime (e.g., the total number of requests handled,
/// divided by the number of seconds the process has been running), it does not offer a sense of recency.
/// Luckily, meters also record three different exponentially-weighted moving average rates: the 1-, 5-, and 15-minute moving averages.
/// </remarks>
/// <param name="name">Name of the metric. Must be unique across all meters in this context.</param>
/// <param name="unit">Description of what the is being measured ( Unit.Requests , Unit.Items etc ) .</param>
/// <param name="rateUnit">Time unit for rates reporting. Defaults to Second ( occurrences / second ).</param>
/// <param name="tag">Optional tag that can be associated with the metric.</param>
/// <returns>Reference to the metric</returns>
public IMeter Meter(string name, Units unit, TimeUnits rateUnit = TimeUnits.Seconds, string tag = null)
{
return new Meter(_context.Meter(name, unit.ToString(), (TimeUnit)rateUnit, tag));
}
示例9: Timer
/// <summary>
/// A timer is basically a histogram of the duration of a type of event and a meter of the rate of its occurrence.
/// </summary>
/// <param name="name">Name of the metric. Must be unique across all timers in this context.</param>
/// <param name="unit">Description of what the is being measured ( Unit.Requests , Unit.Items etc ) .</param>
/// <param name="samplingType">Type of the sampling to use (see SamplingType for details ).</param>
/// <param name="rateUnit">Time unit for rates reporting. Defaults to Second ( occurrences / second ).</param>
/// <param name="durationUnit">Time unit for reporting durations. Defaults to Milliseconds.</param>
/// <param name="tag">Optional tag that can be associated with the metric.</param>
/// <returns>
/// Reference to the metric
/// </returns>
public ITimer Timer(string name, Units unit, SamplingTypes samplingType, TimeUnits rateUnit, TimeUnits durationUnit, string tag = null)
{
return new Timer(_context.Timer(name, unit.ToString(), (SamplingType)samplingType, (TimeUnit)rateUnit, (TimeUnit)durationUnit, tag));
}