Пример #1
0
		public Jpeg2000LosslessActionItem(int time, TimeUnit unit, Expression exprScheduledTime)
			: base("JPEG 2000 Lossless compression action")
		{
			_offsetTime = time;
			_units = unit;
			_exprScheduledTime = exprScheduledTime;
		}
 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";
     }
 }
 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";
     }
 }
        /// <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);
        }
 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;
 }
Пример #6
0
 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";
     }
 }
Пример #7
0
        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);
        }
Пример #8
0
    /// <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_
        });
    }
        /// <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;
        }
Пример #10
0
 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));
 }
Пример #11
0
 public virtual void addTrace(string name, long time, TimeUnit unit)
 {
     if (log.isTraceEnabled())
     {
         log.trace("Trace: " + name + " - " + TimeUnit.MILLISECONDS.convert(time, unit) + " ms");
     }
 }
Пример #12
0
	    /// <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
0
 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;
 }
Пример #14
0
 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";
     }
 }
Пример #15
0
 // ----------------------------------------------------------------------
 public static DateTime CalcTimeMoment( DateTime baseMoment, TimeUnit offsetUnit, long offsetCount = 1, ITimeCalendar calendar = null )
 {
     switch ( offsetUnit )
     {
         case TimeUnit.Tick:
             return baseMoment.AddTicks( offsetCount );
         case TimeUnit.Millisecond:
             DateTime offsetMillisecond = baseMoment.AddSeconds( offsetCount );
             return TimeTrim.Millisecond( offsetMillisecond, offsetMillisecond.Millisecond );
         case TimeUnit.Second:
             DateTime offsetSecond = baseMoment.AddSeconds( offsetCount );
             return TimeTrim.Second( offsetSecond, offsetSecond.Second );
         case TimeUnit.Minute:
             return new Minute(baseMoment, calendar).AddMinutes( ToInt( offsetCount ) ).Start;
         case TimeUnit.Hour:
             return new Hour( baseMoment, calendar ).AddHours( ToInt( offsetCount ) ).Start;
         case TimeUnit.Day:
             return new Day( baseMoment, calendar ).AddDays( ToInt( offsetCount ) ).Start;
         case TimeUnit.Week:
             return new Week( baseMoment, calendar ).AddWeeks( ToInt( offsetCount ) ).Start;
         case TimeUnit.Month:
             return new Month( baseMoment, calendar ).AddMonths( ToInt( offsetCount ) ).Start;
         case TimeUnit.Quarter:
             return new Quarter( baseMoment, calendar ).AddQuarters( ToInt( offsetCount ) ).Start;
         case TimeUnit.Halfyear:
             return new Halfyear( baseMoment, calendar ).AddHalfyears( ToInt( offsetCount ) ).Start;
         case TimeUnit.Year:
             return new Year( baseMoment, calendar ).AddYears( ToInt( offsetCount ) ).Start;
         default:
             throw new InvalidOperationException();
     }
 }
        /// <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,  Int64 inputWindowSize, Int64 predictWindowSize, TimeUnit unit)
            : base((int)inputWindowSize, (int)predictWindowSize)
        {

            _loader = loader;
            SequenceGrandularity =unit;
        }
Пример #17
0
 public long GetSpan(TimeUnit unit)
 {
     switch (unit)
     {
         case TimeUnit.Ticks:
             return GetSpanTicks();
         case TimeUnit.Seconds:
             return GetSpanSeconds();
         case TimeUnit.Minutes:
             return GetSpanMinutes();
         case TimeUnit.Hours:
             return GetSpanHours();
         case TimeUnit.Days:
             return GetSpanDays();
         case TimeUnit.Weeks:
             return GetSpanWeeks();
         case TimeUnit.Fortnights:
             return GetSpanFortnights();
         case TimeUnit.Months:
             return GetSpanMonths();
         case TimeUnit.Years:
             return GetSpanYears();
         case TimeUnit.Scores:
             return GetSpanScores();
         case TimeUnit.Centuries:
             return GetSpanCenturies();
         case TimeUnit.Millennia:
             return GetSpanMillennia();
         default:
             return 0;
     }
 }
 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);
 }
Пример #19
0
        /// <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;
        }
        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);
        }
Пример #21
0
		/// <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";
		}
Пример #22
0
        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);
        }
Пример #23
0
        /// <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);
        }
Пример #24
0
		public Jpeg2000LossyActionItem(int time, TimeUnit unit, Expression exprScheduledTime, float ratio)
			: base("JPEG 2000 Lossy compression action")
		{
			_offsetTime = time;
			_units = unit;
			_exprScheduledTime = exprScheduledTime;
			_ratio = ratio;
		}
Пример #25
0
        protected override void ReportTimer(string name, TimerValue value, Unit unit, TimeUnit rateUnit, TimeUnit durationUnit, MetricTags tags)
        {
            var values = MeterValues(value.Rate, unit, rateUnit)
                .Concat(HistogramValues(value.Histogram, unit, durationUnit))
                .Concat(new[] { new Value("Active Sessions", value.ActiveSessions) });

            Write("Timer", name, values);
        }
Пример #26
0
 public void Advance(TimeUnit unit, long value)
 {
     this.nanoseconds += unit.ToNanoseconds(value);
     if (Advanced != null)
     {
         Advanced(this, EventArgs.Empty);
     }
 }
Пример #27
0
        /// <summary>
        /// 创建心跳时段。
        /// </summary>
        /// <param name="thisTime"></param>
        /// <param name="timeUnit"></param>
        /// <param name="timeLength"></param>
        /// <returns></returns>
        public static BeatTimeRange CrateBeatTimeRange(DateTime thisTime, TimeUnit timeUnit, int timeLength)
        {
            BeatTimeRange timeRange = new BeatTimeRange();

            FillTimeRange(timeRange, thisTime, timeUnit, timeLength);

            return timeRange;
        }
Пример #28
0
 private void CheckConvertOneWay(double value1, TimeUnit unit1, double value2, TimeUnit unit2)
 {
     var convertedValue2 = TimeUnit.Convert(value1, unit1, unit2);
     output.WriteLine($"Expected: {value1} {unit1.Name} = {value2} {unit2.Name}");
     output.WriteLine($"Actual: {value1} {unit1.Name} = {convertedValue2} {unit2.Name}");
     output.WriteLine("");
     Assert.Equal(value2, convertedValue2, 4);
 }
        private schedule(Runnable task, long delay, TimeUnit unit)
        {
            Preconditions.checkState(isOpen.get(), "CloseableExecutorService is closed");

            InternalFutureTask<void> futureTask = new InternalFutureTask<void>(new FutureTask<void>(task, null));
            scheduledExecutorService.schedule(futureTask, delay, unit);
            return futureTask;
        }
Пример #30
0
 public override void ReportMeter(string name, Meter meter, Unit unit, TimeUnit rateUnit)
 {
     this.callback(string.Format(@"Meter. Name:{0}. Value:{1} {2}/{3}/n"
         , name
         , meter.Value.ToString("F2", CultureInfo.InvariantCulture)
         , unit
         , rateUnit));
 }
Пример #31
0
        public static void AwaitForever(System.Func <bool> condition, long checkInterval, TimeUnit unit)
        {
            long sleep = unit.toNanos(checkInterval);

            do
            {
                if (condition())
                {
                    return;
                }
                LockSupport.parkNanos(sleep);
            } while (true);
        }
Пример #32
0
 /// <summary>
 /// <p>
 /// Keep trying a limited number of times, waiting a growing amount of time between attempts,
 /// and then fail by re-throwing the exception.
 /// </summary>
 /// <remarks>
 /// <p>
 /// Keep trying a limited number of times, waiting a growing amount of time between attempts,
 /// and then fail by re-throwing the exception.
 /// The time between attempts is <code>sleepTime</code> mutliplied by a random
 /// number in the range of [0, 2 to the number of retries)
 /// </p>
 /// </remarks>
 public static RetryPolicy ExponentialBackoffRetry(int maxRetries, long sleepTime,
                                                   TimeUnit timeUnit)
 {
     return(new RetryPolicies.ExponentialBackoffRetry(maxRetries, sleepTime, timeUnit));
 }
Пример #33
0
 public RetryUpToMaximumTimeWithFixedSleep(long maxTime, long sleepTime, TimeUnit
                                           timeUnit)
     : base((int)(maxTime / sleepTime), sleepTime, timeUnit)
 {
 }
Пример #34
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static <EXCEPTION extends Exception> void awaitEx(ThrowingSupplier<bool,EXCEPTION> condition, long timeout, java.util.concurrent.TimeUnit unit) throws java.util.concurrent.TimeoutException, EXCEPTION
        public static void AwaitEx <EXCEPTION>(ThrowingSupplier <bool, EXCEPTION> condition, long timeout, TimeUnit unit) where EXCEPTION : Exception
        {
            AwaitEx(condition, timeout, unit, DEFAULT_POLL_INTERVAL, TimeUnit.MILLISECONDS);
        }
Пример #35
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static <EXCEPTION extends Exception> void awaitEx(ThrowingSupplier<bool,EXCEPTION> condition, long timeout, java.util.concurrent.TimeUnit unit, long pollInterval, java.util.concurrent.TimeUnit pollUnit) throws java.util.concurrent.TimeoutException, EXCEPTION
        public static void AwaitEx <EXCEPTION>(ThrowingSupplier <bool, EXCEPTION> condition, long timeout, TimeUnit unit, long pollInterval, TimeUnit pollUnit) where EXCEPTION : Exception
        {
            if (!TryAwaitEx(condition, timeout, unit, pollInterval, pollUnit))
            {
                throw new TimeoutException("Waited for " + timeout + " " + unit + ", but " + condition + " was not accepted.");
            }
        }
 /// <summary>
 /// Returns the string representation of the provided DateTime
 /// </summary>
 /// <param name="timeUnit"></param>
 /// <param name="timeUnitTense"></param>
 /// <param name="unit"></param>
 /// <returns></returns>
 public virtual string DateHumanize(TimeUnit timeUnit, Tense timeUnitTense, int unit)
 {
     return(GetResourceForDate(timeUnit, timeUnitTense, unit));
 }
        private string GetResourceForDate(TimeUnit unit, Tense timeUnitTense, int count)
        {
            string resourceKey = ResourceKeys.DateHumanize.GetResourceKey(unit, timeUnitTense: timeUnitTense, count: count);

            return(count == 1 ? Format(resourceKey) : Format(resourceKey, count));
        }
Пример #38
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static <TYPE> TYPE await(System.Func<TYPE> supplier, System.Predicate<TYPE> predicate, long timeout, java.util.concurrent.TimeUnit timeoutUnit, long pollInterval, java.util.concurrent.TimeUnit pollUnit) throws java.util.concurrent.TimeoutException
        public static TYPE Await <TYPE>(System.Func <TYPE> supplier, System.Predicate <TYPE> predicate, long timeout, TimeUnit timeoutUnit, long pollInterval, TimeUnit pollUnit)
        {
            return(AwaitEx(supplier.get, predicate.test, timeout, timeoutUnit, pollInterval, pollUnit));
        }
        private string GetResourceForTimeSpan(TimeUnit unit, int count)
        {
            string resourceKey = ResourceKeys.TimeSpanHumanize.GetResourceKey(unit, count);

            return(count == 1 ? Format(resourceKey) : Format(resourceKey, count));
        }
Пример #40
0
 /// <summary>
 /// <p>
 /// Keep trying a limited number of times, waiting a fixed time between attempts,
 /// and then fail by re-throwing the exception.
 /// </summary>
 /// <remarks>
 /// <p>
 /// Keep trying a limited number of times, waiting a fixed time between attempts,
 /// and then fail by re-throwing the exception.
 /// </p>
 /// </remarks>
 public static RetryPolicy RetryUpToMaximumCountWithFixedSleep(int maxRetries, long
                                                               sleepTime, TimeUnit timeUnit)
 {
     return(new RetryPolicies.RetryUpToMaximumCountWithFixedSleep(maxRetries, sleepTime
                                                                  , timeUnit));
 }
Пример #41
0
 public RetryUpToMaximumCountWithProportionalSleep(int maxRetries, long sleepTime,
                                                   TimeUnit timeUnit)
     : base(maxRetries, sleepTime, timeUnit)
 {
 }
Пример #42
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static <EXCEPTION extends Exception> boolean tryAwaitEx(ThrowingSupplier<bool,EXCEPTION> condition, long timeout, java.util.concurrent.TimeUnit timeoutUnit, long pollInterval, java.util.concurrent.TimeUnit pollUnit, java.time.Clock clock) throws EXCEPTION
        public static bool TryAwaitEx <EXCEPTION>(ThrowingSupplier <bool, EXCEPTION> condition, long timeout, TimeUnit timeoutUnit, long pollInterval, TimeUnit pollUnit, Clock clock) where EXCEPTION : Exception
        {
            long deadlineMillis    = clock.millis() + timeoutUnit.toMillis(timeout);
            long pollIntervalNanos = pollUnit.toNanos(pollInterval);

            do
            {
                if (condition.Get())
                {
                    return(true);
                }
                LockSupport.parkNanos(pollIntervalNanos);
            } while (clock.millis() < deadlineMillis);
            return(false);
        }
Пример #43
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static <EXCEPTION extends Exception> boolean tryAwaitEx(ThrowingSupplier<bool,EXCEPTION> condition, long timeout, java.util.concurrent.TimeUnit timeoutUnit, long pollInterval, java.util.concurrent.TimeUnit pollUnit) throws EXCEPTION
        public static bool TryAwaitEx <EXCEPTION>(ThrowingSupplier <bool, EXCEPTION> condition, long timeout, TimeUnit timeoutUnit, long pollInterval, TimeUnit pollUnit) where EXCEPTION : Exception
        {
            return(TryAwaitEx(condition, timeout, timeoutUnit, pollInterval, pollUnit, Clock.systemUTC()));
        }
Пример #44
0
 /// <summary>
 /// Advances the given date of the given number of business days and
 /// returns the result.
 /// </summary>
 /// <remarks>The input date is not modified</remarks>
 public DateTime advance(DateTime d, int n, TimeUnit unit, BusinessDayConvention c = BusinessDayConvention.Following, bool endOfMonth = false)
 {
     if (d == null)
     {
         throw new ArgumentException("null date");
     }
     if (n == 0)
     {
         return(adjust(d, c));
     }
     else if (unit == TimeUnit.Days)
     {
         DateTime d1 = d;
         if (n > 0)
         {
             while (n > 0)
             {
                 d1 = d1.AddDays(1);
                 while (isHoliday(d1))
                 {
                     d1 = d1.AddDays(1);
                 }
                 n--;
             }
         }
         else
         {
             while (n < 0)
             {
                 d1 = d1.AddDays(-1);
                 while (isHoliday(d1))
                 {
                     d1 = d1.AddDays(-1);
                 }
                 n++;
             }
         }
         return(d1);
     }
     else if (unit == TimeUnit.Weeks)
     {
         DateTime d1 = d.AddDays(n * 7);
         return(adjust(d1, c));
     }
     else if (unit == TimeUnit.Months)
     {
         DateTime d1 = d.AddMonths(n);
         if (endOfMonth && unit == TimeUnit.Months && isEndOfMonth(d))
         {
             return(this.endOfMonth(d1));
         }
         return(adjust(d1, c));
     }
     else // Years
     {
         DateTime d1 = d.AddYears(n);
         if (endOfMonth && unit == TimeUnit.Years && isEndOfMonth(d))
         {
             return(this.endOfMonth(d1));
         }
         return(adjust(d1, c));
     }
 }
Пример #45
0
 public static string Name(this TimeUnit timeUnit) => timeUnit.AsString(EnumFormat.DisplayName);
Пример #46
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static <TYPE, EXCEPTION extends Exception> TYPE awaitEx(ThrowingSupplier<TYPE,? extends EXCEPTION> supplier, ThrowingPredicate<TYPE, ? extends EXCEPTION> predicate, long timeout, java.util.concurrent.TimeUnit timeoutUnit) throws java.util.concurrent.TimeoutException, EXCEPTION
        public static TYPE AwaitEx <TYPE, EXCEPTION, T1, T2>(ThrowingSupplier <T1> supplier, ThrowingPredicate <T2> predicate, long timeout, TimeUnit timeoutUnit) where EXCEPTION : Exception where T1 : EXCEPTION where T2 : EXCEPTION
        {
            Suppliers.ThrowingCapturingSupplier <TYPE, EXCEPTION> composed = Suppliers.Compose(supplier, predicate);
            AwaitEx(composed, timeout, timeoutUnit);
            return(composed.LastInput());
        }
Пример #47
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static void await(System.Func<boolean> condition, long timeout, java.util.concurrent.TimeUnit timeoutUnit, long pollInterval, java.util.concurrent.TimeUnit pollUnit) throws java.util.concurrent.TimeoutException
        public static void Await(System.Func <bool> condition, long timeout, TimeUnit timeoutUnit, long pollInterval, TimeUnit pollUnit)
        {
            AwaitEx(condition.getAsBoolean, timeout, timeoutUnit, pollInterval, pollUnit);
        }
Пример #48
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static <TYPE> TYPE await(System.Func<TYPE> supplier, System.Predicate<TYPE> predicate, long timeout, java.util.concurrent.TimeUnit timeoutUnit) throws java.util.concurrent.TimeoutException
        public static TYPE Await <TYPE>(System.Func <TYPE> supplier, System.Predicate <TYPE> predicate, long timeout, TimeUnit timeoutUnit)
        {
            return(AwaitEx(throwingSupplier(supplier), throwingPredicate(predicate), timeout, timeoutUnit));
        }
Пример #49
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static void await(System.Func<boolean> condition, long timeout, java.util.concurrent.TimeUnit unit) throws java.util.concurrent.TimeoutException
        public static void Await(System.Func <bool> condition, long timeout, TimeUnit unit)
        {
            AwaitEx(condition.getAsBoolean, timeout, unit);
        }
Пример #50
0
 public RetryUpToMaximumCountWithFixedSleep(int maxRetries, long sleepTime, TimeUnit
                                            timeUnit)
     : base(maxRetries, sleepTime, timeUnit)
 {
 }
Пример #51
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static <TYPE, EXCEPTION extends Exception> TYPE awaitEx(ThrowingSupplier<TYPE,EXCEPTION> supplier, ThrowingPredicate<TYPE,EXCEPTION> predicate, long timeout, java.util.concurrent.TimeUnit timeoutUnit, long pollInterval, java.util.concurrent.TimeUnit pollUnit) throws java.util.concurrent.TimeoutException, EXCEPTION
        public static TYPE AwaitEx <TYPE, EXCEPTION>(ThrowingSupplier <TYPE, EXCEPTION> supplier, ThrowingPredicate <TYPE, EXCEPTION> predicate, long timeout, TimeUnit timeoutUnit, long pollInterval, TimeUnit pollUnit) where EXCEPTION : Exception
        {
            Suppliers.ThrowingCapturingSupplier <TYPE, EXCEPTION> composed = Suppliers.Compose(supplier, predicate);
            AwaitEx(composed, timeout, timeoutUnit, pollInterval, pollUnit);
            return(composed.LastInput());
        }
Пример #52
0
 public static string Description(this TimeUnit timeUnit) => timeUnit.AsString(EnumFormat.Description);
Пример #53
0
        /// <summary>
        /// Returns the rate in the given units of time.
        /// </summary>
        public double Rate(TimeUnit rateUnit)
        {
            var nanos = rateUnit.ToNanos(1);

            return(_rate * nanos);
        }
Пример #54
0
 /// <summary>
 /// <p>
 /// Keep trying for a maximum time, waiting a fixed time between attempts,
 /// and then fail by re-throwing the exception.
 /// </summary>
 /// <remarks>
 /// <p>
 /// Keep trying for a maximum time, waiting a fixed time between attempts,
 /// and then fail by re-throwing the exception.
 /// </p>
 /// </remarks>
 public static RetryPolicy RetryUpToMaximumTimeWithFixedSleep(long maxTime, long sleepTime
                                                              , TimeUnit timeUnit)
 {
     return(new RetryPolicies.RetryUpToMaximumTimeWithFixedSleep(maxTime, sleepTime, timeUnit
                                                                 ));
 }
Пример #55
0
 [PublicAPI] public string ToTimeStr(TimeUnit unit = null, Encoding encoding = null)
 {
     encoding = encoding ?? Encoding.ASCII;
     return($"[P95: {P95.ToTimeStr(unit, encoding)}] [P0: {P0.ToTimeStr(unit, encoding)}]; [P50: {P50.ToTimeStr(unit, encoding)}]; [P100: {P100.ToTimeStr(unit, encoding)})]");
 }
Пример #56
0
 private MeterMetric(string eventType, TimeUnit rateUnit)
 {
     EventType = eventType;
     RateUnit  = rateUnit;
 }
Пример #57
0
        /// <summary>
        /// Delete banker's order
        /// </summary>
        public static string Init_HKCDL(ConnectionDetails connectionDetails, string OrderId, string Receiver, string ReceiverIBAN, string ReceiverBIC, decimal Amount, string Usage, DateTime FirstTimeExecutionDay, TimeUnit timeUnit, string Rota, int ExecutionDay)
        {
            Log.Write("Starting job HKCDL: Delete bankers order");

            string segments = "HKCDL:" + SEGNUM.SETVal(3) + ":1+" + connectionDetails.IBAN + ":" + connectionDetails.BIC + "+urn?:iso?:std?:iso?:20022?:tech?:xsd?:pain.001.001.03+@@";

            var sepaMessage = pain00100103.Create(connectionDetails.AccountHolder, connectionDetails.IBAN, connectionDetails.BIC, Receiver, ReceiverIBAN, ReceiverBIC, Amount, Usage, new DateTime(1999, 1, 1)).Replace("'", "");

            segments = segments.Replace("@@", "@" + sepaMessage.Length + "@") + sepaMessage;

            segments += "++" + OrderId + "+" + FirstTimeExecutionDay.ToString("yyyyMMdd") + ":" + (char)timeUnit + ":" + Rota + ":" + ExecutionDay + "'";

            segments = HKTAN.Init_HKTAN(segments);

            SEG.NUM = SEGNUM.SETInt(4);

            string message = FinTSMessage.Create(connectionDetails.HBCIVersion, Segment.HNHBS, Segment.HNHBK, connectionDetails.BlzPrimary, connectionDetails.UserId, connectionDetails.Pin, Segment.HISYN, segments, Segment.HIRMS, SEG.NUM);
            var    TAN     = FinTSMessage.Send(connectionDetails.Url, message);

            Segment.HITAN = Helper.Parse_String(Helper.Parse_String(TAN, "HITAN", "'").Replace("?+", "??"), "++", "+").Replace("??", "?+");

            Helper.Parse_Message(TAN);

            return(TAN);
        }
        public IActionItem <ServerActionContext> Compile(XmlElement xmlNode)
        {
            if (xmlNode.Attributes["time"] == null)
            {
                throw new XmlActionCompilerException(
                          "Unexpected missing time attribute for jpeg-extended scheduling action");
            }
            if (xmlNode.Attributes["unit"] == null)
            {
                throw new XmlActionCompilerException(
                          "Unexpected missing unit attribute for jpeg-extended scheduling action");
            }

            int quality;

            if (false == int.TryParse(xmlNode.Attributes["quality"].Value, out quality))
            {
                throw new XmlActionCompilerException("Unable to parse quality value for jpeg-extended scheduling rule");
            }

            int time;

            if (false == int.TryParse(xmlNode.Attributes["time"].Value, out time))
            {
                throw new XmlActionCompilerException("Unable to parse time value for jpeg-extended scheduling rule");
            }

            string xmlUnit = xmlNode.Attributes["unit"].Value;

            // this will throw exception if the unit is not defined
            TimeUnit unit = (TimeUnit)Enum.Parse(typeof(TimeUnit), xmlUnit, true);

            string refValue = xmlNode.Attributes["refValue"] != null ? xmlNode.Attributes["refValue"].Value : null;

            bool convertFromPalette = false;

            if (xmlNode.Attributes["convertFromPalette"] != null)
            {
                if (false == bool.TryParse(xmlNode.Attributes["convertFromPalette"].Value, out convertFromPalette))
                {
                    throw new XmlActionCompilerException("Unable to parse convertFromPalette value for jpeg-extended scheduling rule");
                }
            }

            if (!String.IsNullOrEmpty(refValue))
            {
                if (xmlNode["expressionLanguage"] != null)
                {
                    string     language      = xmlNode["expressionLanguage"].Value;
                    Expression scheduledTime = CreateExpression(refValue, language);
                    return(new JpegExtendedActionItem(time, unit, scheduledTime, quality, convertFromPalette));
                }
                else
                {
                    Expression scheduledTime = CreateExpression(refValue);
                    return(new JpegExtendedActionItem(time, unit, scheduledTime, quality, convertFromPalette));
                }
            }

            return(new JpegExtendedActionItem(time, unit, quality, convertFromPalette));
        }
Пример #59
0
 public void Advance(TimeUnit unit, long value)
 {
     // DEVNOTE: Use test clock to advance the timer for testing purposes
 }
Пример #60
0
 /// <summary>Creates a new away time that measures the time in the specified time unit.</summary>
 public NumberAwayTime(TimeUnit unit)
 {
     TimeUnit = unit;
 }