本文整理汇总了C#中TimeUnit类的典型用法代码示例。如果您正苦于以下问题:C# TimeUnit类的具体用法?C# TimeUnit怎么用?C# TimeUnit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TimeUnit类属于命名空间,在下文中一共展示了TimeUnit类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetAveragedSpectrum
public Domain.ISpectrum GetAveragedSpectrum(double startRt, double endRt, TimeUnit timeUnits, double mzLower, double mzUpper)
{
List<int> scanList = GetScanList(startRt, endRt);
SpectrumList spectrumList = run.spectrumList;
int timePoints = spectrumList.size();
List<Domain.ISpectrum> msValuesList = new List<Domain.ISpectrum>();
List<int> tempScanList = new List<int>();
if (scanList == null)
{
// If scan list is empty then take entire chromatographic range.
for (int i = 0; i < timePoints; i++)
{
tempScanList.Add(i);
}
}
else
{
tempScanList = scanList;
}
for (int i = 0; i < tempScanList.Count; i++)
{
msValuesList.Add(spectrumExtractor.GetSpectrum(tempScanList[i], timeUnits, mzLower, mzUpper));
}
// Merge scans
return SpectrumHelper.CreateAveragedSpectrum(msValuesList);
}
开发者ID:pol,项目名称:MassSpecStudio,代码行数:31,代码来源:AveragedSpectrumExtractor.cs
示例2: ReportTimer
protected override void ReportTimer(string name, TimerValue value, Unit unit, TimeUnit rateUnit, TimeUnit durationUnit)
{
var values = MeterValues(value.Rate.Scale(rateUnit), unit, rateUnit)
.Concat(HistogramValues(value.Histogram.Scale(durationUnit), unit, durationUnit));
Write("Timer", name, values);
}
开发者ID:kvarv,项目名称:Metrics.NET,代码行数:7,代码来源:CSVReporter.cs
示例3: Jpeg2000LosslessActionItem
public Jpeg2000LosslessActionItem(int time, TimeUnit unit, Expression exprScheduledTime)
: base("JPEG 2000 Lossless compression action")
{
_offsetTime = time;
_units = unit;
_exprScheduledTime = exprScheduledTime;
}
开发者ID:nhannd,项目名称:Xian,代码行数:7,代码来源:Jpeg2000LosslessActionItem.cs
示例4: Code
public String Code(TimeUnit unit)
{
switch (unit)
{
case TimeUnit.SECONDS:
return "sec";
case TimeUnit.MINUTES:
return "min";
case TimeUnit.HOURS:
return "hr";
case TimeUnit.DAYS:
return "d";
case TimeUnit.WEEKS:
return "w";
case TimeUnit.FORTNIGHTS:
return "fn";
case TimeUnit.MONTHS:
return "m";
case TimeUnit.YEARS:
return "y";
case TimeUnit.DECADES:
return "dec";
case TimeUnit.SCORES:
return "sc";
case TimeUnit.CENTURIES:
return "c";
case TimeUnit.MILLENNIA:
return "m";
default:
return "unk";
}
}
开发者ID:OperatorOverload,项目名称:encog-cs,代码行数:32,代码来源:EnglishTimeUnitNames.cs
示例5: Verify
public static void Verify(string expectedString, int unit, TimeUnit timeUnit, Tense tense)
{
var deltaFromNow = new TimeSpan();
unit = Math.Abs(unit);
if (tense == Tense.Past)
unit = -unit;
switch (timeUnit)
{
case TimeUnit.Second:
deltaFromNow = TimeSpan.FromSeconds(unit);
break;
case TimeUnit.Minute:
deltaFromNow = TimeSpan.FromMinutes(unit);
break;
case TimeUnit.Hour:
deltaFromNow = TimeSpan.FromHours(unit);
break;
case TimeUnit.Day:
deltaFromNow = TimeSpan.FromDays(unit);
break;
case TimeUnit.Month:
deltaFromNow = TimeSpan.FromDays(unit*31);
break;
case TimeUnit.Year:
deltaFromNow = TimeSpan.FromDays(unit*366);
break;
}
VerifyWithCurrentDate(expectedString, deltaFromNow);
VerifyWithDateInjection(expectedString, deltaFromNow);
}
开发者ID:JonasJensen,项目名称:Humanizer,代码行数:33,代码来源:DateHumanize.cs
示例6: Humanize
/// <summary>
/// Turns a TimeSpan into a human readable form. E.g. 1 day.
/// </summary>
/// <param name="timeSpan"></param>
/// <param name="precision">The maximum number of time units to return.</param>
/// <param name="countEmptyUnits">Controls whether empty time units should be counted towards maximum number of time units. Leading empty time units never count.</param>
/// <param name="culture">Culture to use. If null, current thread's UI culture is used.</param>
/// <param name="maxUnit">The maximum unit of time to output.</param>
/// <param name="minUnit">The minimum unit of time to output.</param>
/// <returns></returns>
public static string Humanize(this TimeSpan timeSpan, int precision, bool countEmptyUnits, CultureInfo culture = null, TimeUnit maxUnit = TimeUnit.Week, TimeUnit minUnit = TimeUnit.Millisecond)
{
var timeParts = CreateTheTimePartsWithUperAndLowerLimits(timeSpan, culture, maxUnit, minUnit);
timeParts = SetPrecisionOfTimeSpan(timeParts, precision, countEmptyUnits);
return ConcatenateTimeSpanParts(timeParts);
}
开发者ID:gabrielrainha,项目名称:Humanizer,代码行数:17,代码来源:TimeSpanHumanizeExtensions.cs
示例7: MarketMLDataSet
public MarketMLDataSet(IMarketLoader loader, int inputWindowSize, int predictWindowSize, TimeUnit unit)
: base(inputWindowSize, predictWindowSize)
{
this._xa2ee854ac63ea89c = new Dictionary<int, TemporalPoint>();
this._x5cd320770c3df353 = loader;
this.SequenceGrandularity = unit;
}
开发者ID:neismit,项目名称:emds,代码行数:7,代码来源:MarketMLDataSet.cs
示例8: BuildFormatTimePart
private static string BuildFormatTimePart(IFormatter cultureFormatter, TimeUnit timeUnitType, int amountOfTimeUnits)
{
// Always use positive units to account for negative timespans
return amountOfTimeUnits != 0
? cultureFormatter.TimeSpanHumanize(timeUnitType, Math.Abs(amountOfTimeUnits))
: null;
}
开发者ID:gabrielrainha,项目名称:Humanizer,代码行数:7,代码来源:TimeSpanHumanizeExtensions.cs
示例9: Plural
public String Plural(TimeUnit unit)
{
switch (unit)
{
case TimeUnit.Seconds:
return "seconds";
case TimeUnit.Minutes:
return "minutes";
case TimeUnit.Hours:
return "hours";
case TimeUnit.Days:
return "days";
case TimeUnit.Weeks:
return "weeks";
case TimeUnit.Fortnights:
return "fortnights";
case TimeUnit.Months:
return "months";
case TimeUnit.Years:
return "years";
case TimeUnit.Decades:
return "decades";
case TimeUnit.Scores:
return "scores";
case TimeUnit.Centuries:
return "centures";
case TimeUnit.Millennia:
return "millennia";
default:
return "unknowns";
}
}
开发者ID:jongh0,项目名称:MTree,代码行数:32,代码来源:EnglishTimeUnitNames.cs
示例10: GetElapsedString
/// <summary>
/// ArrayFormat elapsed time to a nice format
/// if (forceTimeUnit is null)
/// the timeInSecond will be formated to min, ms, microSec or nanoSec base on its value
/// otherwise
/// it will display the timeInSecond in the forceTimeUnit
/// </summary>
public static string GetElapsedString(double timeInSecond, TimeUnit? forceTimeUnit = null)
{
if (forceTimeUnit.HasValue)
{
switch (forceTimeUnit)
{
case TimeUnit.MicroSecond:
return (timeInSecond*1000000.0).ToString("0") + " mcs";
case TimeUnit.Second:
return (timeInSecond).ToString("0.##") + " s";
default:
return (timeInSecond*1000.0).ToString("0.##") + " ms";
}
}
if (timeInSecond >= 60)
{
return (timeInSecond/60.0).ToString("0.#") + " min";
}
if (timeInSecond >= 1)
{
return timeInSecond.ToString("0.#") + " s";
}
if (timeInSecond >= 0.001)
{
return (timeInSecond*1000.0).ToString("0") + " ms";
}
if (timeInSecond >= 0.000001)
{
return (timeInSecond*1000000.0).ToString("0") + " mcs";
}
return (timeInSecond*1000000000.0).ToString("0") + " ns";
}
开发者ID:ntung,项目名称:ToolsPack.Net,代码行数:39,代码来源:StopwatchDisplayer.cs
示例11: addTrace
public virtual void addTrace(string name, long time, TimeUnit unit)
{
if (log.isTraceEnabled())
{
log.trace("Trace: " + name + " - " + TimeUnit.MILLISECONDS.convert(time, unit) + " ms");
}
}
开发者ID:shayhatsor,项目名称:curator,代码行数:7,代码来源:DefaultTracerDriver.cs
示例12: TimeSpanHumanize
/// <summary>
/// Returns the string representation of the provided TimeSpan
/// </summary>
/// <param name="timeUnit">Must be less than or equal to TimeUnit.Week</param>
/// <param name="unit"></param>
/// <param name="strategy">Optional TimeSpanFormatStrategy, default is Long</param>
/// <returns></returns>
/// <exception cref="System.ArgumentOutOfRangeException">Is thrown when timeUnit is larger than TimeUnit.Week</exception>
public virtual string TimeSpanHumanize(TimeUnit timeUnit, int unit, TimeSpanFormatStrategy strategy = TimeSpanFormatStrategy.Long)
{
if (timeUnit > TimeUnit.Week)
throw new ArgumentOutOfRangeException("timeUnit", "There's no meaningful way to humanize passed timeUnit.");
return GetResourceForTimeSpan(timeUnit, unit, strategy);
}
开发者ID:bkmr,项目名称:Humanizer,代码行数:15,代码来源:DefaultFormatter.cs
示例13: MarketMLDataSet
/// <summary>
/// Initializes a new instance of the <see cref="MarketMLDataSet"/> class.
/// </summary>
/// <param name="loader">The loader.</param>
/// <param name="inputWindowSize">Size of the input window.</param>
/// <param name="predictWindowSize">Size of the predict window.</param>
/// <param name="unit">The time unit to use.</param>
public MarketMLDataSet(IMarketLoader loader, int inputWindowSize, int predictWindowSize, TimeUnit unit)
: base(inputWindowSize, predictWindowSize)
{
_loader = loader;
SequenceGrandularity =unit;
}
开发者ID:encog,项目名称:encog-silverlight-core,代码行数:14,代码来源:MarketMLDataSet.cs
示例14: Plural
public String Plural(TimeUnit unit)
{
switch (unit)
{
case TimeUnit.SECONDS:
return "seconds";
case TimeUnit.MINUTES:
return "minutes";
case TimeUnit.HOURS:
return "hours";
case TimeUnit.DAYS:
return "days";
case TimeUnit.WEEKS:
return "weeks";
case TimeUnit.FORTNIGHTS:
return "fortnights";
case TimeUnit.MONTHS:
return "months";
case TimeUnit.YEARS:
return "years";
case TimeUnit.DECADES:
return "decades";
case TimeUnit.SCORES:
return "scores";
case TimeUnit.CENTURIES:
return "centures";
case TimeUnit.MILLENNIA:
return "millennia";
default:
return "unknowns";
}
}
开发者ID:OperatorOverload,项目名称:encog-cs,代码行数:32,代码来源:EnglishTimeUnitNames.cs
示例15: TimeLine
public TimeLine(c000069 p0)
: base(p0)
{
this.f00027b = 10.0;
this.f00027c = 2.5;
this.f00000a = true;
this.f0000b3 = TimeUnit.f0000b4;
this.f000031 = 0.6f;
this.f000033 = 0.6f;
this.f00000b = 15;
this.f00005b = new List<string>();
this.f000059 = null;
this.f00087c = new float[1];
this.f00087d = new float[1];
this.f000069 = 0.0;
this.f000074 = double.PositiveInfinity;
this.f000075 = 0.0;
this.f00007d = 100.0;
base.f000031 = 10f;
base.f000033 = 1.5f;
this.f00002a = new c00006a(base.f000029);
this.m000097(this.f00002a);
this.f00002a.m000375(0.5f);
this.f00002a.m000376(1f);
this.f00002a.m00037f(new delegate06f(this.m0000a8));
this.f00002a.m000386(0f, this.m000150());
this.f00002a.f00002a = new struct055(0f, 0.8789063f);
this.f00002a.f0000bf = new struct055(0.00390625f, 0.8789063f);
this.f00002a.f0000c0 = new struct055(0.00390625f, 0.8828125f);
this.f00002a.f000243 = new struct055(0f, 0.8828125f);
this.f00002a.m00007f("TimeLine position bar");
this.m0003ae();
base.m0000d0(new delegate06f(this.m0000a6));
}
开发者ID:bing2008,项目名称:CastNetGame,代码行数:34,代码来源:TimeLine.cs
示例16: Meter
/// <summary>
/// Initializes a new instance of the <see cref=" Meter"/> class by using
/// the specified meter name, rate unit and clock.
/// </summary>
/// <param name="config">
/// A <see cref="MetricConfig"/> containing the configuration settings
/// for the metric.
/// </param>
/// <param name="rate_unit">
/// The time unit of the meter's rate.
/// </param>
/// <param name="context">
/// A <see cref="MetricContext"/> that contains the shared
/// <see cref="Mailbox{T}"/> and <see cref="Clock"/>.
/// </param>
internal Meter(MetricConfig config, TimeUnit rate_unit,
MetricContext context) : base(config, context) {
const string kStatistic = "statistic";
mean_rate_ = new MeanRate(
config.WithAdditionalTag(new Tag(kStatistic, "mean_rate")), rate_unit,
context);
ewma_1_rate_ = ExponentialWeightedMovingAverage
.ForOneMinute(
config.WithAdditionalTag(new Tag(kStatistic, "ewma_m1_rate")),
rate_unit, context);
ewma_5_rate_ = ExponentialWeightedMovingAverage
.ForFiveMinutes(
config.WithAdditionalTag(new Tag(kStatistic, "ewma_m5_rate")),
rate_unit, context);
ewma_15_rate_ = ExponentialWeightedMovingAverage
.ForFifteenMinutes(
config.WithAdditionalTag(new Tag(kStatistic, "ewma_m15_rate")),
rate_unit, context);
metrics_ = new ReadOnlyCollection<IMetric>(
new IMetric[] {
mean_rate_, ewma_1_rate_, ewma_5_rate_, ewma_15_rate_
});
}
开发者ID:joethinh,项目名称:nohros-must,代码行数:43,代码来源:Meter.cs
示例17: TimeSpanHumanize
/// <summary>
/// Returns the string representation of the provided TimeSpan
/// </summary>
/// <param name="timeUnit">Must be less than or equal to TimeUnit.Week</param>
/// <param name="unit"></param>
/// <returns></returns>
/// <exception cref="System.ArgumentOutOfRangeException">Is thrown when timeUnit is larger than TimeUnit.Week</exception>
public virtual string TimeSpanHumanize(TimeUnit timeUnit, int unit)
{
if (timeUnit > TimeUnit.Week)
throw new ArgumentOutOfRangeException(nameof(timeUnit), "There's no meaningful way to humanize passed timeUnit.");
return GetResourceForTimeSpan(timeUnit, unit);
}
开发者ID:gabrielrainha,项目名称:Humanizer,代码行数:14,代码来源:DefaultFormatter.cs
示例18: Code
public String Code(TimeUnit unit)
{
switch (unit)
{
case TimeUnit.Seconds:
return "sec";
case TimeUnit.Minutes:
return "min";
case TimeUnit.Hours:
return "hr";
case TimeUnit.Days:
return "d";
case TimeUnit.Weeks:
return "w";
case TimeUnit.Fortnights:
return "fn";
case TimeUnit.Months:
return "m";
case TimeUnit.Years:
return "y";
case TimeUnit.Decades:
return "dec";
case TimeUnit.Scores:
return "sc";
case TimeUnit.Centuries:
return "c";
case TimeUnit.Millennia:
return "m";
default:
return "unk";
}
}
开发者ID:jongh0,项目名称:MTree,代码行数:32,代码来源:EnglishTimeUnitNames.cs
示例19: ReportTimer
protected override void ReportTimer(string name, TimerValue value, Unit unit, TimeUnit rateUnit, TimeUnit durationUnit, MetricTags tags)
{
this.WriteMetricName(name);
this.WriteValue("Active Sessions", value.ActiveSessions.ToString());
this.WriteMeter(value.Rate, unit, rateUnit);
this.WriteHistogram(value.Histogram, unit, durationUnit);
}
开发者ID:dynamicdeploy,项目名称:Metrics.NET,代码行数:7,代码来源:HumanReadableReport.cs
示例20: Humanize
/// <summary>
/// Calculate rate for the quantity of bytes and interval defined by this instance
/// </summary>
/// <param name="timeUnit">Unit of time to calculate rate for (defaults is per second)</param>
/// <param name="format">The string format to use for the number of bytes</param>
/// <returns></returns>
public string Humanize(string format, TimeUnit timeUnit = TimeUnit.Second)
{
TimeSpan displayInterval;
string displayUnit;
if (timeUnit == TimeUnit.Second)
{
displayInterval = TimeSpan.FromSeconds(1);
displayUnit = "s";
}
else if (timeUnit == TimeUnit.Minute)
{
displayInterval = TimeSpan.FromMinutes(1);
displayUnit = "min";
}
else if (timeUnit == TimeUnit.Hour)
{
displayInterval = TimeSpan.FromHours(1);
displayUnit = "hour";
}
else
throw new NotSupportedException("timeUnit must be Second, Minute, or Hour");
return new ByteSize(Size.Bytes / Interval.TotalSeconds * displayInterval.TotalSeconds)
.Humanize(format) + '/' + displayUnit;
}
开发者ID:ninwnj,项目名称:Humanizer,代码行数:32,代码来源:ByteRate.cs
注:本文中的TimeUnit类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论