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


C# TimeUnit.ToString方法代码示例

本文整理汇总了C#中TimeUnit.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# TimeUnit.ToString方法的具体用法?C# TimeUnit.ToString怎么用?C# TimeUnit.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TimeUnit的用法示例。


在下文中一共展示了TimeUnit.ToString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: getUsers

        public  UsersResult    getUsers(TimeUnit timeUnit, String start, int duration)
        {
            String url = REPORT_HOST_NAME + REPORT_USER_PATH
                    + "?time_unit=" + timeUnit.ToString()
                    + "&start=" + start + "&duration=" + duration;
            String auth = Base64.getBase64Encode(this.appKey + ":" + this.masterSecret);
            ResponseWrapper response = this.sendGet(url, auth, null);

            return UsersResult.fromResponse(response);
        }
开发者ID:twxstar,项目名称:jpush-api-csharp-client,代码行数:10,代码来源:ReportClient.cs

示例2: GetResourceKey

            /// <summary>
            /// Generates Resource Keys accordning to convention.
            /// </summary>
            /// <param name="timeUnit">Time unit</param>
            /// <param name="timeUnitTense">Is time unit in future or past</param>
            /// <param name="count">Number of units, default is One.</param>
            /// <returns>Resource key, like DateHumanize_SingleMinuteAgo</returns>
            public static string GetResourceKey(TimeUnit timeUnit, Tense timeUnitTense, int count = 1)
            {
                ValidateRange(count);

                if (count == 0) 
                    return Now;

                var singularity = count == 1 ? Single : Multiple;
                var tense = timeUnitTense == Tense.Future ? FromNow : Ago;
                var unit = timeUnit.ToString().ToQuantity(count, ShowQuantityAs.None);
                return DateTimeFormat.FormatWith(singularity, unit, tense);
            }
开发者ID:ninwnj,项目名称:Humanizer,代码行数:19,代码来源:ResourceKeys.DateHumanize.cs

示例3: ScheduledReporter

 /// <summary>
 /// Creates a new <see cref="ScheduledReporter"/> instance
 /// </summary>
 /// <param name="registry">the <see cref="MetricRegistry"/> containing the metrics this reporter will report</param>
 /// <param name="name">the reporter's name</param>
 /// <param name="filter">the filter for which metrics to report</param>
 /// <param name="rateUnit">a unit of time</param>
 /// <param name="durationUnit">a unit of time</param>
 protected ScheduledReporter(MetricRegistry registry,
                             string name,
                             MetricFilter filter,
                             TimeUnit rateUnit,
                             TimeUnit durationUnit)
 {
     this.registry = registry;
     this.filter = filter;
     this.rateFactor = rateUnit.ToSeconds(1);
     this.rateUnit = calculateRateUnit(rateUnit);
     this.durationFactor = 1.0 / durationUnit.ToNanos(1);
     this.durationUnit = durationUnit.ToString().ToLowerInvariant();
 }
开发者ID:thattolleyguy,项目名称:metrics-net,代码行数:21,代码来源:ScheduledReporter.cs

示例4: AddTimeLength

 /// <summary>
 /// 增加时长。
 /// </summary>
 /// <param name="thisTime"></param>
 /// <param name="timeUnit"></param>
 /// <param name="timeLength"></param>
 /// <returns></returns>
 public static DateTime AddTimeLength(DateTime thisTime, TimeUnit timeUnit, int timeLength)
 {
     switch (timeUnit)
     {
         case TimeUnit.Hour:
             return thisTime.AddHours(timeLength);
         case TimeUnit.Minute:
             return thisTime.AddMinutes(timeLength);
         case TimeUnit.Second:
             return thisTime.AddSeconds(timeLength);
         default:
             throw new Exception("无法识别时间单位:" + timeUnit.ToString());
     }
 }
开发者ID:jihadbird,项目名称:firespider,代码行数:21,代码来源:TimeRangeUtil.cs

示例5: EditDivisionWindow

        public EditDivisionWindow(double timeValue,TimeUnit timeUnit)
        {
            InitializeComponent();
            resultTimeUnit = timeUnit;
            resultTimeValue = timeValue;

            Text_TimeValue.Text = timeValue.ToString();
            foreach (string typeName in Enum.GetNames(typeof(TimeUnit))) {
                Combo_TimeUnit.Items.Add(typeName);
                if (typeName == timeUnit.ToString()) {
                    Combo_TimeUnit.SelectedItem = typeName;
                }
            }
        }
开发者ID:kodack64,项目名称:NIDAQ_Control,代码行数:14,代码来源:EditDivisionWindow.xaml.cs

示例6: FillTimeRange

        /// <summary>
        /// 设置时段。
        /// </summary>
        /// <param name="thisTime"></param>
        /// <param name="timeUnit"></param>
        /// <param name="timeLength"></param>
        public static void FillTimeRange(WorkingTimeRange timeRange, DateTime thisTime, TimeUnit timeUnit, int timeLength)
        {
            //取得当前时间所在时段的起始分钟数。
            TimeSpan ts = thisTime - thisTime.Date;

            //设置时段范围。
            double count;
            int startOffset;

            switch (timeUnit)
            {
                case TimeUnit.Hour:
                    count = ts.TotalHours / timeLength;
                    startOffset = (int)count * timeLength;

                    timeRange.StartTime = thisTime.Date.AddHours(startOffset);
                    timeRange.EndTime = timeRange.StartTime.AddHours(timeLength);
                    break;
                case TimeUnit.Minute:
                    count = ts.TotalMinutes / timeLength;
                    startOffset = (int)count * timeLength;

                    timeRange.StartTime = thisTime.Date.AddMinutes(startOffset);
                    timeRange.EndTime = timeRange.StartTime.AddMinutes(timeLength);
                    break;
                case TimeUnit.Second:
                    count = ts.TotalSeconds / timeLength;
                    startOffset = (int)count * timeLength;

                    timeRange.StartTime = thisTime.Date.AddSeconds(startOffset);
                    timeRange.EndTime = timeRange.StartTime.AddSeconds(timeLength);
                    break;
                default:
                    throw new Exception("无法识别时间单位:" + timeUnit.ToString());
            }
        }
开发者ID:jihadbird,项目名称:firespider,代码行数:42,代码来源:TimeRangeUtil.cs

示例7: calculateRateUnit

 private string calculateRateUnit(TimeUnit unit)
 {
     string s = unit.ToString().ToLowerInvariant();
     return s.Substring(0, s.Length - 1);
 }
开发者ID:thattolleyguy,项目名称:metrics-net,代码行数:5,代码来源:ScheduledReporter.cs


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