Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 取得时段。
        /// </summary>
        /// <param name="thisTime"></param>
        /// <returns></returns>
        public BeatTimeRange GetTimeRange(DateTime thisTime)
        {
            if (thisTime.Date == this._thisDate)
            {
                if (this.currentTimeRange != null && this.currentTimeRange.ContainsTime(thisTime))
                {
                    return currentTimeRange;
                }

                this.currentTimeRange = null;

                foreach (BeatTimeRange timeRange in this._timeRanges)
                {
                    if (timeRange.ContainsTime(thisTime))
                    {
                        this.currentTimeRange = timeRange;

                        return timeRange;
                    }
                }
            }
            return null;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 复位。
        /// </summary>
        public override void Reset()
        {
            this._thisDate = DateTime.Now.Date;

            foreach (BeatTimeRange timeRange in _timeRanges)
            {
                timeRange.IsRelative = true;
                timeRange.IsBeated = false;
            }

            this.currentTimeRange = null;

            //触发复位事件。
            DoReset();
        }