Beispiel #1
0
        /// <summary>
        /// Gets current rate (frequency) value converted converted to specifed time unit.
        /// </summary>
        /// <param name="unit">
        /// Time unit.
        /// </param>
        public double Frequency(TimeUnit unit)
        {
            var f = Frequency();

            switch (unit)
            {
            case Eon.TimeUnit.Tick:
                return(f == 0 ? 0.0D : (double)f / _timeUnit.Ticks);

            case Eon.TimeUnit.Millisecond:
                return(f == 0 ? 0.0D : f / _timeUnit.TotalMilliseconds);

            case Eon.TimeUnit.Second:
                return(f == 0 ? 0.0D : f / _timeUnit.TotalSeconds);

            case Eon.TimeUnit.Minute:
                return(f == 0 ? 0.0D : f / _timeUnit.TotalMinutes);

            case Eon.TimeUnit.Hour:
                return(f == 0 ? 0.0D : f / _timeUnit.TotalHours);

            case Eon.TimeUnit.Day:
                return(f == 0 ? 0.0D : f / _timeUnit.TotalDays);

            default:
                throw new ArgumentOutOfRangeException(message: $"Value is not supported.{Environment.NewLine}\tValue:{unit.FmtStr().GNLI2()}", paramName: nameof(unit)).SetErrorCode(code: GeneralErrorCodes.Operation.Params.Illegal);
            }
        }