当前位置: 首页>>代码示例>>C#>>正文


C# Units.ToString方法代码示例

本文整理汇总了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);
      }

    }
开发者ID:arthurliebhardt,项目名称:MyWeather.Forms,代码行数:14,代码来源:WeatherService.cs

示例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);
			}

		}
开发者ID:yalbik,项目名称:dev-days-labs,代码行数:14,代码来源:WeatherService.cs

示例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);
      }

    }
开发者ID:arthurliebhardt,项目名称:MyWeather.Forms,代码行数:14,代码来源:WeatherService.cs

示例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));
 }
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:11,代码来源:MetricsContext.cs

示例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);
 }
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:11,代码来源:MetricsContext.cs

示例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));
 }
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:14,代码来源:MetricsContext.cs

示例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));
 }
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:12,代码来源:MetricsContext.cs

示例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));
 }
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:19,代码来源:MetricsContext.cs

示例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));
 }
开发者ID:blehnen,项目名称:DotNetWorkQueue,代码行数:16,代码来源:Metrics.cs


注:本文中的Units.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。