public override void OnActionExecuting(ActionExecutingContext c) { var key = string.Concat(Name, "-", c.HttpContext.Request.UserHostAddress); var allowExecute = false; if (HttpRuntime.Cache[key] == null) { HttpRuntime.Cache.Add(key, true, // is this the smallest data we can have? null, // no dependencies DateTime.Now.AddMilliseconds(Milliseconds), // absolute expiration Cache.NoSlidingExpiration, CacheItemPriority.Low, null); // no callback allowExecute = true; } if (!allowExecute) { if (String.IsNullOrEmpty(Message)) { Message = "You may only perform this action every {n} milliseconds."; } c.Result = new ContentResult { Content = Message.Replace("{n}", Milliseconds.ToString()) }; // see 409 - http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html c.HttpContext.Response.StatusCode = (int)HttpStatusCode.Conflict; } }
public void ShouldBeTimeSpanOfProvided() { //Arrange Milliseconds subject = new Milliseconds(500); //Act TimeSpan actual = subject; //Assert actual.Should().Be(TimeSpan.FromMilliseconds(500)); }
public string ToString(string format) { format = format.Replace("YYYY", Years.ToString()); format = format.Replace("MM", Months.ToString()); format = format.Replace("DD", Days.ToString()); format = format.Replace("hh", Hours.ToString()); format = format.Replace("mm", Minutes.ToString()); format = format.Replace("ss", Seconds.ToString()); format = format.Replace("ms", Milliseconds.ToString()); return format; }
private void EnterTimeButton_Click(object sender, EventArgs e) { AthleteCurr.setAttributesByID(TimingAthleteBox); SpeedSkatingEventCurr.setEventID(TimingSpeedSkatingEventBox); RefereeCurr.setTime(Minutes, Seconds, Milliseconds); RefereeCurr.enterAthleteTime(AthleteCurr, SpeedSkatingEventCurr); SpeedSkatingEventCurr.printCurrentEventResultsToGrid(CurrentEventResults); TimingSpeedSkatingEventBox.ClearSelected(); Minutes.ClearSelected(); Seconds.ClearSelected(); Milliseconds.ClearSelected(); }
public void Remaining_ReturnRemainingTimeInterval() { //Arrange TimeInterval interval = new Milliseconds(321); TimeInterval elapsed = new Milliseconds(123); CountdownTime subject = new PrivateCtor <CountdownTime>(interval, elapsed); //Act TimeSpan actual = subject.Remaining(); //Assert actual.Should().Be(TimeSpan.FromMilliseconds(198)); }
public void ShouldBeElapsedTimeIntervals() { //Arrange TimeInterval precision = new Milliseconds(500); MockCounter mockCounter = new MockCounter.Builder().Value(new NumberOf(10)).Build(); ElapsedTimeIntervals subject = new ElapsedTimeIntervals(precision, mockCounter); //Act TimeSpan actual = subject; //Assert actual.Should().Be(TimeSpan.FromMilliseconds(500 * 10)); }
public void ShouldProvideDifference() { //Arrange TimeInterval minuend = new Milliseconds(500); TimeInterval subtrahend = new Milliseconds(100); DifferenceOfTimeInterval subject = new DifferenceOfTimeInterval(minuend, subtrahend); //Act TimeSpan actual = subject; //Assert actual.Should().Be(TimeSpan.FromMilliseconds(400)); }
public override string ToString() { switch (Type) { case PropertyType.Null: return("null"); case PropertyType.Calculated: return("calculated"); case PropertyType.Bool: return(Bool.ToString()); case PropertyType.String: return("string: " + StringHandle.ToString()); case PropertyType.MultiValue: return("multi: " + MultiValueHandle.ToString()); case PropertyType.Enum: return("enum: " + Enum.ToString()); case PropertyType.Color: return("color: " + Color.ToString()); case PropertyType.Integer: return(Integer.ToString() + " (integer)"); case PropertyType.Fractional: return(Fractional.ToString() + " (fractional)"); case PropertyType.Percentage: return(Percentage.ToString() + "%"); case PropertyType.AbsLength: return(Points.ToString() + "pt (" + Inches.ToString() + "in, " + Millimeters.ToString() + "mm) (abs)"); case PropertyType.RelLength: return(Points.ToString() + "pt (" + Inches.ToString() + "in, " + Millimeters.ToString() + "mm) (rel)"); case PropertyType.HtmlFontUnits: return(HtmlFontUnits.ToString() + " (html font units)"); case PropertyType.RelHtmlFontUnits: return(RelativeHtmlFontUnits.ToString() + " (relative html font units)"); case PropertyType.Multiple: return(Integer.ToString() + "*"); case PropertyType.Pixels: return(Pixels.ToString() + "px"); case PropertyType.Ems: return(Ems.ToString() + "em"); case PropertyType.Exs: return(Exs.ToString() + "ex"); case PropertyType.Milliseconds: return(Milliseconds.ToString() + "ms"); case PropertyType.kHz: return(kHz.ToString() + "kHz"); case PropertyType.Degrees: return(Degrees.ToString() + "deg"); } return("unknown value type"); }
/// <inheritdoc /> protected override async Task <Result <Unit, IError> > Run( IStateMonad stateMonad, CancellationToken cancellationToken) { var ms = await Milliseconds.Run(stateMonad, cancellationToken); if (ms.IsFailure) { return(ms.ConvertFailure <Unit>()); } await Task.Delay(ms.Value, cancellationToken); return(Unit.Default); }
public override int GetHashCode() { unchecked { var hashCode = Years.GetHashCode(); hashCode = (hashCode * 397) ^ Months.GetHashCode(); hashCode = (hashCode * 397) ^ Weeks.GetHashCode(); hashCode = (hashCode * 397) ^ Days.GetHashCode(); hashCode = (hashCode * 397) ^ Hours.GetHashCode(); hashCode = (hashCode * 397) ^ Minutes.GetHashCode(); hashCode = (hashCode * 397) ^ Seconds.GetHashCode(); hashCode = (hashCode * 397) ^ Milliseconds.GetHashCode(); hashCode = (hashCode * 397) ^ Microseconds.GetHashCode(); return hashCode; } }
public override int GetHashCode() { unchecked { int hashCode = Years.GetHashCode(); hashCode = (hashCode * 397) ^ Months.GetHashCode(); hashCode = (hashCode * 397) ^ Days.GetHashCode(); hashCode = (hashCode * 397) ^ Hours.GetHashCode(); hashCode = (hashCode * 397) ^ Minutes.GetHashCode(); hashCode = (hashCode * 397) ^ Seconds.GetHashCode(); hashCode = (hashCode * 397) ^ Milliseconds.GetHashCode(); hashCode = (hashCode * 397) ^ DaysInMonth.GetHashCode(); return(hashCode); } }
public override string ToString() => string.Join(',', new string[] { SurveyType.ToString(), WaterDepth.ToString(), X.ToString(), Y.ToString(), GNSSAltitude.ToString(), GNSSHeading.ToString(), GNSSSpeed.ToString(), MagneticHeading.ToString(), MinRange.ToString(), MaxRange.ToString(), WaterTemperature.ToString(), WaterSpeed.ToString(), HardwareTime.ToString(), Frequency.ToString(), Milliseconds.ToString() + '\n' });
string IUrlParameter.GetString(IConnectionConfigurationValues settings) { if (this == MinusOne) { return("-1"); } if (this == Zero) { return("0"); } if (Factor.HasValue && Interval.HasValue) { return(ToString()); } return(Milliseconds.ToString()); }
public override string ToString() { if (Addresses.Length != 0) { return($"{Addresses.Length.ToString("#,#", CultureInfo.InvariantCulture)} results -" + $" {Access.Process.Id.ToString("x8").ToUpper()}-" + $"{Access.Process.MainModule.ModuleName} " + $"({Milliseconds.ToString("0.000 ms")})"); } else { return($"we've not got results -" + $" {Access.Process.Id.ToString("x8").ToUpper()}-" + $"{Access.Process.MainModule.ModuleName} " + $"({Milliseconds.ToString("0.000 ms")})"); } }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) hashCode = hashCode * 59 + Years.GetHashCode(); hashCode = hashCode * 59 + Months.GetHashCode(); hashCode = hashCode * 59 + Days.GetHashCode(); hashCode = hashCode * 59 + Hours.GetHashCode(); hashCode = hashCode * 59 + Minutes.GetHashCode(); hashCode = hashCode * 59 + Milliseconds.GetHashCode(); hashCode = hashCode * 59 + TotalYears.GetHashCode(); hashCode = hashCode * 59 + TotalMonths.GetHashCode(); hashCode = hashCode * 59 + TotalDays.GetHashCode(); hashCode = hashCode * 59 + TotalHours.GetHashCode(); hashCode = hashCode * 59 + TotalMinutes.GetHashCode(); hashCode = hashCode * 59 + TotalSeconds.GetHashCode(); hashCode = hashCode * 59 + TotalMilliseconds.GetHashCode(); hashCode = hashCode * 59 + Ticks.GetHashCode(); return(hashCode); } }
public override void OnActionExecuting(ActionExecutingContext c) { var key = string.Concat(Name, "-", c.HttpContext.Request.HttpContext.Connection.RemoteIpAddress); if (!Cache.TryGetValue(key, out bool entry)) { var cacheEntryOptions = new MemoryCacheEntryOptions() .SetAbsoluteExpiration(TimeSpan.FromMilliseconds(Milliseconds)); Cache.Set(key, true, cacheEntryOptions); } else { if (string.IsNullOrEmpty(Message)) { Message = "You may only perform this action every {n} milliseconds."; } c.Result = new ContentResult { Content = Message.Replace("{n}", Milliseconds.ToString()) }; c.HttpContext.Response.StatusCode = (int)HttpStatusCode.Conflict; } }
public SystemClock() { int ticks = 0, secs = 0, mins = 0, hours = 0, days = 0; var timer = this.CreateTimer(); var interval = timer.Delay; timer.Tick += delegate { ticks += interval; Milliseconds?.Invoke(ticks); if (ticks >= 1000) { ++secs; ticks = 0; Seconds?.Invoke(secs); if (secs == 60) { ++mins; secs = 0; Minutes?.Invoke(mins); if (mins == 60) { ++hours; mins = 0; Hours?.Invoke(hours); if (hours == 24) { ++days; hours = 0; Days?.Invoke(days); } } } } }; timer.Start(); }
public override string ToString() { return(TotalHours.ToString().PadLeft(2, '0') + ":" + Minutes.ToString().PadLeft(2, '0') + ":" + Seconds.ToString().PadLeft(2, '0') + "." + Milliseconds.ToString().PadLeft(3, '0')); }
public override string ToString() { return(Years + "y " + Months + "m " + Days + "d " + Hours + "h " + Minutes + "min " + Seconds + "s " + Milliseconds.ToString("000") + "ms"); }
public static extern UInt32 WaitForSingleObject(IntPtr hHandle, Milliseconds dwMilliseconds);
/// <summary> /// Returns true if OutputDateDifference instances are equal /// </summary> /// <param name="other">Instance of OutputDateDifference to be compared</param> /// <returns>Boolean</returns> public bool Equals(OutputDateDifference other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Years == other.Years || Years.Equals(other.Years) ) && ( Months == other.Months || Months.Equals(other.Months) ) && ( Days == other.Days || Days.Equals(other.Days) ) && ( Hours == other.Hours || Hours.Equals(other.Hours) ) && ( Minutes == other.Minutes || Minutes.Equals(other.Minutes) ) && ( Milliseconds == other.Milliseconds || Milliseconds.Equals(other.Milliseconds) ) && ( TotalYears == other.TotalYears || TotalYears.Equals(other.TotalYears) ) && ( TotalMonths == other.TotalMonths || TotalMonths.Equals(other.TotalMonths) ) && ( TotalDays == other.TotalDays || TotalDays.Equals(other.TotalDays) ) && ( TotalHours == other.TotalHours || TotalHours.Equals(other.TotalHours) ) && ( TotalMinutes == other.TotalMinutes || TotalMinutes.Equals(other.TotalMinutes) ) && ( TotalSeconds == other.TotalSeconds || TotalSeconds.Equals(other.TotalSeconds) ) && ( TotalMilliseconds == other.TotalMilliseconds || TotalMilliseconds.Equals(other.TotalMilliseconds) ) && ( Ticks == other.Ticks || Ticks.Equals(other.Ticks) )); }
private async Task TestMultiple(int NrObjects, int ArraySize, int BulkSize, bool AssertIndividually, int?LogStatisticsEvery) { DateTime Start = DateTime.Now; List <FileStatistics> Stat = null; List <double> Milliseconds = null; int i = 0, j; Simple[] Objects = new Simple[NrObjects]; Simple[] Block = new Simple[ArraySize]; Simple Obj2; ObjectSerializer Serializer = this.provider.GetObjectSerializerEx(typeof(Simple)); if (BulkSize > 1) { await this.provider.StartBulk(); } while (i < NrObjects) { for (j = 0; j < ArraySize; j++) { Block[j] = CreateSimple(this.MaxStringLength); Objects[i++] = Block[j]; } if (ArraySize > 1) { await this.file.SaveNewObjects(Block, Serializer); } else { await this.file.SaveNewObject(Block[0]); } if (BulkSize > 1 && i % BulkSize == 0) { await this.provider.EndBulk(); await this.provider.StartBulk(); } if (AssertIndividually) { Console.Out.WriteLine(); Console.Out.WriteLine(i.ToString() + " objects:"); Console.Out.WriteLine(new string('-', 80)); await AssertConsistent(this.file, this.provider, i, Objects[i - 1], true); } if (LogStatisticsEvery.HasValue && i % LogStatisticsEvery.Value == 0) { if (Stat is null) { Milliseconds = new List <double>(); Stat = new List <FileStatistics>(); } Milliseconds.Add((DateTime.Now - Start).TotalMilliseconds / LogStatisticsEvery.Value); Stat.Add((await this.file.ComputeStatistics()).Key); Start = DateTime.Now; } } if (BulkSize > 1) { await this.provider.EndBulk(); } for (i = 0; i < NrObjects; i++) { Obj2 = await this.file.LoadObject <Simple>(Objects[i].ObjectId); DBFilesObjectSerializationTests.AssertEqual(Objects[i], Obj2); } if (!AssertIndividually) { await AssertConsistent(this.file, this.provider, NrObjects, null, true); } if (Stat != null) { Variables v = new Variables() { { "Stat", Stat.ToArray() }, { "ms", Milliseconds.ToArray() }, { "StepSize", LogStatisticsEvery.Value } }; Expression Exp = new Expression("[ms,Stat.BlockSize,Stat.NrBlocks,Stat.NrBytesUsed,Stat.NrBytesUnused,Stat.NrBytesTotal," + "Stat.Usage,Stat.NrObjects,Stat.MinObjectSize,Stat.MaxObjectSize,Stat.AverageObjectSize,Stat.MinDepth,Stat.MaxDepth," + "Stat.NrBlockLoads,Stat.NrCacheLoads,Stat.NrBlockSaves,Stat.MinObjectsPerBlock,Stat.MaxObjectsPerBlock," + "Stat.AverageObjectsPerBlock,Stat.MinBytesUsedPerBlock,Stat.MaxBytesUsedPerBlock,Stat.AverageBytesUsedPerBlock]T"); Console.Out.WriteLine("ms, BlockSize, NrBlocks, NrBytesUsed, NrBytesUnused, NrBytesTotal, " + "Usage, NrObjects, MinObjectSize, MaxObjectSize, AverageObjectSize, MinDepth, MaxDepth, " + "NrBlockLoads, NrCacheLoads, NrBlockSaves,Min(Obj/Block),Max(Obj/Block),Avg(Obj/Block)," + "Min(UsedBytes/Block),Max(UsedBytes/Block),Avg(UsedBytes/Block)"); Console.Out.WriteLine(new string('-', 80)); Console.Out.WriteLine(Exp.Evaluate(v).ToString()); } }
/// <summary> /// Returns a hash code for this instance. /// </summary> /// <returns> /// A hash code for this instance, suitable for use in hashing algorithms and data /// structures like a hash table. /// </returns> public override int GetHashCode() { return(Milliseconds.GetHashCode()); }
public bool Equals(Milliseconds other) { return(other.Value == Value); }
public override int GetHashCode() => StaticTimeValue.HasValue ? StaticTimeValue.Value.GetHashCode() // ReSharper disable once NonReadonlyMemberInGetHashCode : Milliseconds.GetHashCode();
/// <summary> /// Compares the current object with another object of the same type. /// </summary> /// <param name="other">An object to compare with this object.</param> /// <returns> /// A 32-bit signed integer that indicates the relative order of the objects being compared. /// The return value has the following meanings: /// <list type = "table"> /// <listheader> /// <term>Value</term> /// <description>Meaning</description> /// </listheader> /// <item> /// <term>< 0</term> /// <description>This object is less than the <paramref name = "other" /> parameter.</description> /// </item> /// <item> /// <term>0</term> /// <description>This object is equal to <paramref name = "other" />.</description> /// </item> /// <item> /// <term>> 0</term> /// <description>This object is greater than <paramref name = "other" />.</description> /// </item> /// </list> /// </returns> public int CompareTo(Offset other) { return(Milliseconds.CompareTo(other.Milliseconds)); }
public override int GetHashCode() => StaticTimeValue.HasValue ? StaticTimeValue.Value.GetHashCode() : Milliseconds.GetHashCode();
private async Task TestMultiple(int c, bool AssertIndividually, int?LogStatisticsEvery) { DateTime Start = DateTime.Now; List <FileStatistics> Stat = null; List <double> Milliseconds = null; int i; Simple[] Objects = new Simple[c]; Simple Obj2; for (i = 0; i < c; i++) { Objects[i] = CreateSimple(this.MaxStringLength); await this.file.SaveNewObject(Objects[i]); if (AssertIndividually) { Console.Out.WriteLine(); Console.Out.WriteLine((i + 1).ToString() + " objects:"); Console.Out.WriteLine(new string('-', 80)); await AssertConsistent(this.file, this.provider, i + 1, Objects[i], true); } if (LogStatisticsEvery.HasValue && (i + 1) % LogStatisticsEvery.Value == 0) { if (Stat == null) { Milliseconds = new List <double>(); Stat = new List <FileStatistics>(); } Milliseconds.Add((DateTime.Now - Start).TotalMilliseconds / LogStatisticsEvery.Value); Stat.Add(await this.file.ComputeStatistics()); Start = DateTime.Now; } } for (i = 0; i < c; i++) { Obj2 = await this.file.LoadObject <Simple>(Objects[i].ObjectId); DBFilesObjectSerializationTests.AssertEqual(Objects[i], Obj2); } if (!AssertIndividually) { await AssertConsistent(this.file, this.provider, c, null, true); } if (Stat != null) { Variables v = new Variables() { { "Stat", Stat.ToArray() }, { "ms", Milliseconds.ToArray() }, { "StepSize", LogStatisticsEvery.Value } }; Expression Exp = new Expression("[ms,Stat.BlockSize,Stat.NrBlocks,Stat.NrBytesUsed,Stat.NrBytesUnused,Stat.NrBytesTotal," + "Stat.Usage,Stat.NrObjects,Stat.MinObjectSize,Stat.MaxObjectSize,Stat.AverageObjectSize,Stat.MinDepth,Stat.MaxDepth," + "Stat.NrBlockLoads,Stat.NrCacheLoads,Stat.NrBlockSaves,Stat.MinObjectsPerBlock,Stat.MaxObjectsPerBlock," + "Stat.AverageObjectsPerBlock,Stat.MinBytesUsedPerBlock,Stat.MaxBytesUsedPerBlock,Stat.AverageBytesUsedPerBlock]T"); Console.Out.WriteLine("ms, BlockSize, NrBlocks, NrBytesUsed, NrBytesUnused, NrBytesTotal, " + "Usage, NrObjects, MinObjectSize, MaxObjectSize, AverageObjectSize, MinDepth, MaxDepth, " + "NrBlockLoads, NrCacheLoads, NrBlockSaves,Min(Obj/Block),Max(Obj/Block),Avg(Obj/Block)," + "Min(UsedBytes/Block),Max(UsedBytes/Block),Avg(UsedBytes/Block)"); Console.Out.WriteLine(new string('-', 80)); Console.Out.WriteLine(Exp.Evaluate(v).ToString()); } }
public int CompareTo(object obj) { return(Milliseconds.CompareTo(((Track)obj).Milliseconds)); }
public long?GetTotalMicroseconds() { return(Seconds.GetValueOrDefault() * 1_000_000L + Milliseconds.GetValueOrDefault() * 1_000L + Microseconds.GetValueOrDefault()); }
public bool Equals(Milliseconds other) { return other.Value == Value; }
public IDisposable every(Milliseconds value) { return new Signal(value.Value, _action, true); }
public IDisposable onceAfter(Milliseconds value) { return new Signal(value.Value, _action, false); }