本文整理汇总了C#中TimeUnit类的典型用法代码示例。如果您正苦于以下问题:C# TimeUnit类的具体用法?C# TimeUnit怎么用?C# TimeUnit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TimeUnit类属于命名空间,在下文中一共展示了TimeUnit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例3: Jpeg2000LosslessActionItem
public Jpeg2000LosslessActionItem(int time, TimeUnit unit, Expression exprScheduledTime)
: base("JPEG 2000 Lossless compression action")
{
_offsetTime = time;
_units = unit;
_exprScheduledTime = exprScheduledTime;
}
示例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";
}
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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";
}
}
示例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";
}
示例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");
}
}
示例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);
}
示例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;
}
示例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";
}
}
示例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));
}