Esempio n. 1
0
    private static DateTime GetUniversalTimeFromEnvironmentTickCount(this ClockAggregateRoot clock, int environmentTickCount)
    {
        Assert.IsNotNull(clock);
        var clockState    = clock.GetAggregateState();
        var milliseconds  = environmentTickCount - clockState.EnvironmentTickCount;
        var universalTime = clockState.UniversalTime.AddMilliseconds(milliseconds);

        return(universalTime);
    }
Esempio n. 2
0
    public static void Get(this ClockAggregateRoot clock, out long stopwatchTimestamp, out int environmentTickCount, out DateTime universalTime,
                           out DateTime localTime)
    {
        var clockState = clock.GetAggregateState();

        stopwatchTimestamp   = clockState.StopwatchTimestamp;
        environmentTickCount = clockState.EnvironmentTickCount;
        universalTime        = clockState.UniversalTime;
        localTime            = clockState.LocalTime;
    }
Esempio n. 3
0
    public static DateTime GetUniversalTimeFromStopwatchTimestamp(this ClockAggregateRoot clock, long stopwatchTimestamp)
    {
        Assert.IsNotNull(clock);
        var clockState          = clock.GetAggregateState();
        var stopwatchTicks      = stopwatchTimestamp - clockState.StopwatchTimestamp;
        var timeSpanTicksDouble = stopwatchTicks * StopwatchConstants.TimeSpanTicksPerStopwatchTick;
        var timeSpanTicks       = (long)Math.Round(timeSpanTicksDouble);
        var universalTime       = clockState.UniversalTime.AddTicks(timeSpanTicks);

        return(universalTime);
    }
Esempio n. 4
0
    public static void GetFromStopwatchTimestamp(this ClockAggregateRoot clock, long stopwatchTimestamp, out int environmentTickCount,
                                                 out DateTime universalTime)
    {
        Assert.IsNotNull(clock);
        var clockState     = clock.GetAggregateState();
        var stopwatchTicks = stopwatchTimestamp - clockState.StopwatchTimestamp;

        var environmentTicksDouble = stopwatchTicks * StopwatchConstants.MillisecondsPerTick;
        var environmentTicks       = (int)Math.Round(environmentTicksDouble);

        environmentTickCount = clockState.EnvironmentTickCount + environmentTicks;

        var timeSpanTicksDouble = stopwatchTicks * StopwatchConstants.TimeSpanTicksPerStopwatchTick;
        var timeSpanTicks       = (long)Math.Round(timeSpanTicksDouble);

        universalTime = clockState.UniversalTime.AddTicks(timeSpanTicks);
    }