private string GetShortString() { StringBuilder sb = new StringBuilder(); if (Hours > 0) { sb.Append(Hours.ToString() + ":"); } if (Minutes > 0) { if (sb.Length == 0) { sb.Append(Minutes.ToString() + ":"); } else { sb.Append(Minutes.ToString("00") + ":"); } } if (sb.Length == 0) { sb.Append(Seconds.ToString() + ","); } else { sb.Append(Seconds.ToString("00") + ","); } sb.Append(Miliseconds.ToString("000")); return(sb.ToString()); }
public void Update(PerspectiveCamera camera, Seconds elapsed) { if (this.state == CutsceneState.Stopped && Keyboard.GetState().IsKeyDown(Keys.I)) { this.state = CutsceneState.Starting; } if (this.state != CutsceneState.Stopped) { if (this.Waypoints.Count < 2) { return; } switch (this.state) { case CutsceneState.Starting: this.DoStart(camera); break; case CutsceneState.Running: this.DoRun(camera, elapsed); break; } } }
public IEnumerator ClocksTicking() { do { timeElapsed += Time.deltaTime; TimePassed = Mathf.Clamp01((totalTime - timeElapsed) / totalTime); Timer.fillAmount = TimePassed; Minutes = Mathf.Clamp(Mathf.FloorToInt((totalTime - timeElapsed) / 60f), 0, Mathf.Infinity); Seconds = Mathf.Clamp(Mathf.FloorToInt((totalTime - timeElapsed) % 60f), 0, Mathf.Infinity); MinutesText.text = Minutes.ToString(); SecondsText.text = Seconds.ToString(); if (Minutes < 10) { MinutesText.text = "0" + Minutes.ToString(); } if (Seconds < 10) { SecondsText.text = "0" + Seconds.ToString(); } yield return(null); }while (Timer.fillAmount > 0); if (Faild != null) { Faild(); } }
public void ShowTimer() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(Minutes.ToString()); if (Seconds >= 10) { stringBuilder.Append(":"); stringBuilder.Append(Seconds.ToString()); } else { stringBuilder.Append(":0"); stringBuilder.Append(Seconds.ToString()); } if (Milliseconds >= 100) { stringBuilder.Append(":"); stringBuilder.Append(Milliseconds.ToString()); } else if (Milliseconds >= 10) { stringBuilder.Append(":0"); stringBuilder.Append(Milliseconds.ToString()); } else { stringBuilder.Append(":00"); stringBuilder.Append(Milliseconds.ToString()); } Console.WriteLine(stringBuilder.ToString()); }
public override void OnActionExecuting(ActionExecutingContext c) { //TODO: some one can abuse this by blocking access to some one else by changing RemoteIpAddress header frequently // TODO: change on doing work first principle, before asking for some action client first need to encrypt some random phrase or get token for action var key = string.Concat(Name, "-", c.HttpContext.Request.HttpContext.Connection.RemoteIpAddress); if (!Cache.TryGetValue(key, out bool entry)) { var cacheEntryOptions = new MemoryCacheEntryOptions() .SetAbsoluteExpiration(TimeSpan.FromSeconds(Seconds)); Cache.Set(key, true, cacheEntryOptions); } else { if (string.IsNullOrEmpty(Message)) { Message = "You may only perform this action every {n} seconds."; } c.Result = new ContentResult { Content = Message.Replace("{n}", Seconds.ToString()) }; c.HttpContext.Response.StatusCode = (int)HttpStatusCode.Conflict; } }
public string ToString(string format, IFormatProvider formatProvider) { //Lyyymmssdddd int indexOfL = format.IndexOf("L", 0, format.Length); string yToReplace = GetStringToReplace(format, "d"); string mToReplace = GetStringToReplace(format, "m"); string sToReplace = GetStringToReplace(format, "s"); string output = format.Replace("L", Str); if (yToReplace != string.Empty) { output = output.Replace(yToReplace, Degrees.ToString()); } if (mToReplace != string.Empty) { output = output.Replace(mToReplace, Minutes.ToString()); } if (sToReplace != string.Empty) { output = output.Replace(sToReplace, Seconds.ToString()); } return(output); //throw new NotImplementedException(); }
public override int GetHashCode() { int hash = 1; if (Hours != 0) { hash ^= Hours.GetHashCode(); } if (Minutes != 0) { hash ^= Minutes.GetHashCode(); } if (Seconds != 0) { hash ^= Seconds.GetHashCode(); } if (Nanos != 0) { hash ^= Nanos.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
internal void PrintSecond() { Seconds takeSecondString = (Seconds)GetNumberOfEnum(Second); string secondString = GetNullToNineString(Second); Console.WriteLine("Сейчас {0} {1}", secondString, takeSecondString); }
public void Update(PerspectiveCamera perspectiveCamera, Seconds elapsed) { for (var i = 0; i < this.FlightPlans.Count; i++) { var flightPlan = this.FlightPlans[i]; var pose = this.Poses.Get(flightPlan.Entity); if (flightPlan.Maneuvers.Count > 0) { var maneuver = flightPlan.Maneuvers.Peek(); maneuver.Update(pose, elapsed); if (maneuver.Completed) { flightPlan.Maneuvers.Dequeue(); } } else { this.Completed.Add(flightPlan.Entity); } } for (var i = 0; i < this.Completed.Count; i++) { var entity = this.Completed[i]; this.FlightPlans.Remove(entity); } this.Completed.Clear(); }
public override void OnActionExecuting(ActionExecutingContext c) { var key = string.Concat(Name, "-", c.HttpContext.Request.UserHostAddress); var allowExecute = false; // var cache = HttpRuntime.Cache; var cache = c.HttpContext.Cache; if (cache[key] == null) { cache.Add(key, true, // is this the smallest data we can have? null, // no dependencies DateTime.Now.AddSeconds(Seconds), // 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} seconds."; } c.Result = new ContentResult { Content = Message.Replace("{n}", Seconds.ToString()) }; // see 409 - http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html c.HttpContext.Response.StatusCode = (int)HttpStatusCode.Conflict; } }
public LerpManeuver(Vector3 targetPosition, float targetYaw, float targetPitch, Seconds duration) { this.TargetPosition = targetPosition; this.TargetYaw = targetYaw; this.TargetPitch = targetPitch; this.Duration = duration; }
public void Update(PerspectiveCamera camera, Seconds elapsed) { for (var i = 0; i < this.Emitters.Count; i++) { this.Emitters[i].Update(elapsed); } }
public DateTime?GetNextTime(DateTime current) { if (SecondType == CronFieldType.Specified && !Seconds.Any()) { throw new ArgumentException("Seconds are Empty."); } if (MinuteType == CronFieldType.Specified && !Minutes.Any()) { throw new ArgumentException("Minutes are Empty."); } if (HourType == CronFieldType.Specified && !Hours.Any()) { throw new ArgumentException("Hours are Empty."); } if (DayType == CronFieldType.Specified && !Days.Any()) { throw new ArgumentException("Days are Empty."); } if (MonthType == CronFieldType.Specified && !Months.Any()) { throw new ArgumentException("Months are Empty."); } if (DayOfWeekType == CronFieldType.Specified && !DayOfWeeks.Any()) { throw new ArgumentException("DayOfWeeks are Empty."); } if (YearType == CronFieldType.Specified && !Years.Any()) { throw new ArgumentException("Years are Empty."); } return(NextSecond(current.Year, current.Month, current.Day, current.Hour, current.Minute, current.Second)); }
public void Seconds_Constructor_Gradians_ReturnsTrue() { Seconds kut = new Seconds(45 * 60 * 60); Seconds kutTest = new Seconds(new Gradians(50)); Assert.IsTrue((kut - kutTest).Angle < tolerance); }
public override void OnActionExecuting(ActionExecutingContext c) { var key = VaryByIp ? string.Concat(Name, "-", c.HttpContext.Request.HttpContext.Connection.RemoteIpAddress) : Name; if (!Cache.TryGetValue(key, out bool entry)) { var cacheEntryOptions = new MemoryCacheEntryOptions() .SetAbsoluteExpiration(TimeSpan.FromSeconds(Seconds)); Cache.Set(key, true, cacheEntryOptions); } else { if (string.IsNullOrEmpty(Message)) { Message = "You may only perform this action every {n} seconds."; } c.Result = new ContentResult { Content = Message.Replace("{n}", Seconds.ToString()) }; c.HttpContext.Response.StatusCode = (int)HttpStatusCode.Conflict; } }
public void Seconds_Constructor_Degrees_ReturnsTrue() { Seconds kut = new Seconds(45 * 60 * 60); Seconds kutTest = new Seconds(new Degrees(45)); Assert.IsTrue((kut - kutTest).Angle < tolerance); }
public void Seconds_Constructor_DMS_ReturnsTrue() { Seconds kut = new Seconds(45 * 60 * 60); Seconds kutTest = new Seconds(new HMS(45, 0, 0)); Assert.IsTrue((kut - kutTest).Angle < tolerance); }
public void Seconds_Constructor_Hours_ReturnsTrue() { Seconds kut = new Seconds(45 * 60 * 60); Seconds kutTest = new Seconds(new Hours(3)); Assert.IsTrue((kut - kutTest).Angle < tolerance, (kut - kutTest).ToString()); }
public void Seconds_Constructor_Radians_ReturnsTrue() { Seconds kut = new Seconds(45 * 60 * 60); Seconds kutTest = new Seconds(new Radians(Math.PI / 4)); Assert.IsTrue((kut - kutTest).Angle < tolerance, (kut - kutTest).ToString()); }
static MetresPerSecond DoMathsWithStructs() { Metres tenKms = 10 * 1000; Seconds oneHour = 60 * 60; return(tenKms / oneHour); }
public override void OnActionExecuting(HttpActionContext actionContext) { 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.AddSeconds(Seconds), // 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} seconds."; } actionContext.Response = actionContext.Request.CreateResponse( HttpStatusCode.Conflict, Message.Replace("{n}", Seconds.ToString()) ); } }
public void Update(PerspectiveCamera perspectiveCamera, Seconds elapsed) { for (var i = 0; i < this.ReactionControllers.Count; i++) { var rcs = this.ReactionControllers[i]; var newPosition = this.Poses.Get(rcs.Entity).Position; UpdateAccelerationAndVelocity(rcs, newPosition, elapsed); for (var e = 0; e < rcs.Emitters.Length; e++) { var emitter = this.Emitters.Get(rcs.Emitters[e]); var dot = Vector3.Dot(emitter.Direction, -Vector3.Normalize(rcs.Acceleration)); if (dot > rcs.EmitterReactionRange) { emitter.StartVelocity = rcs.Velocity; emitter.Enabled = true; } else { emitter.Enabled = false; } } } }
public override void Draw(Graphics drawer, Bitmap[] images, WatchState state) { AmPm?.Draw(drawer, images, state); var hours = AmPm == null ? state.Time.Hour : state.Time.Hour % 12; var drawingOrder = DrawingOrder ?? 0x1234; foreach (var position in DrawingOrderIterator.Iterate(drawingOrder)) { switch (position) { case DrawingOrderPosition.HourTens: Hours?.Tens?.Draw(drawer, images, hours % 100 / 10); break; case DrawingOrderPosition.HourOnes: Hours?.Ones?.Draw(drawer, images, hours % 10); break; case DrawingOrderPosition.MinuteTens: Minutes?.Tens?.Draw(drawer, images, state.Time.Minute % 100 / 10); break; case DrawingOrderPosition.MinuteOnes: Minutes?.Ones?.Draw(drawer, images, state.Time.Minute % 10); break; default: Logger.Warn("Not supported element {0} in DrawingOrder value", position); break; } } Seconds?.Draw(drawer, images, state.Time.Second); }
public void Update(PerspectiveCamera camera, Seconds elapsed, GBuffer gBuffer, Pass pass) { this.Camera = camera; this.Elapsed = elapsed; this.GBuffer = gBuffer; this.Pass = pass; }
public override void OnActionExecuting(ActionExecutingContext actionContext) { var key = string.Concat(Name, "-", actionContext.HttpContext.Request.GetIp()); var allowExecute = false; if (ContextBase.CacheRead(key) == null) { ContextBase.CacheInsertWithSeconds(key, true, Seconds); allowExecute = true; } if (allowExecute) { return; } if (!Message.HasValue()) { Message = "You may only perform this action every {n} seconds."; } actionContext.Result = new ContentResult { Content = Message.Replace("{n}", Seconds.ToString(CultureInfo.InvariantCulture)) }; // see 429 - Rate Limit Exceeded HTTP error actionContext.HttpContext.Response.StatusCode = 429; }
/// <summary> /// Returns true if OrgApacheSlingDistributionTriggerImplScheduledDistributionTriggeProperties instances are equal /// </summary> /// <param name="other">Instance of OrgApacheSlingDistributionTriggerImplScheduledDistributionTriggeProperties to be compared</param> /// <returns>Boolean</returns> public bool Equals(OrgApacheSlingDistributionTriggerImplScheduledDistributionTriggeProperties other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Name == other.Name || Name != null && Name.Equals(other.Name) ) && ( Path == other.Path || Path != null && Path.Equals(other.Path) ) && ( Seconds == other.Seconds || Seconds != null && Seconds.Equals(other.Seconds) ) && ( ServiceName == other.ServiceName || ServiceName != null && ServiceName.Equals(other.ServiceName) )); }
public override void OnLoad() { CanSave = true; MessageBox.Text = Message; //the minimum time span must be 1 if (Seconds == 0) { Seconds = 1; } SecondsBox.Text = Seconds.ToString(CultureInfo.InvariantCulture); //we need to check if the message and the number of seconds are setted correctly string errorString = CheckValidityMessage(); if (!errorString.Equals(string.Empty)) { textInvalid.Text = errorString; textInvalid.Visibility = Visibility.Visible; return; } errorString = CheckValiditySeconds(); if (!errorString.Equals(string.Empty)) { textInvalid.Text = errorString; } textInvalid.Visibility = CanSave ? Visibility.Collapsed : Visibility.Visible; }
/// <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 :) if (Name != null) { hashCode = hashCode * 59 + Name.GetHashCode(); } if (Path != null) { hashCode = hashCode * 59 + Path.GetHashCode(); } if (Seconds != null) { hashCode = hashCode * 59 + Seconds.GetHashCode(); } if (ServiceName != null) { hashCode = hashCode * 59 + ServiceName.GetHashCode(); } return(hashCode); } }
protected DateTime?NextSecond(int year, int month, int day, int hour, int minute, int second) { switch (SecondType) { case CronFieldType.Any: if (second < 59) { return(new DateTime(year, month, day, hour, minute, second + 1)); } else { return(NextMinute(year, month, day, hour, minute, 0)); } case CronFieldType.Specified: var values = Seconds.Where(x => x > second); if (values.Any()) { return(new DateTime(year, month, day, hour, minute, values.First())); } else { return(NextMinute(year, month, day, hour, minute, Seconds.First())); } default: throw new NotImplementedException(); } }
public void DMS_Implicit_Seconds_ReturnsTrue() { DMS dms = new DMS(0, 0, 31.1); Seconds s = dms; Assert.IsTrue(Math.Abs(s.Angle - 31.1) < tolerance, "Kut u stupnjevima: " + s.Angle.ToString()); }
public static Dictionary Dict = new Dictionary(); //Список всех формул #endregion Fields #region Methods static void Main() { var f = new Formula//создание одной формулы { Name = "Acceleration", Measure = "м/с^2" }; //(для примера-формула ускорения) //составляющие формулы. f.Oneform.Add(new OneElementInFormula(0,"м/с",1)); f.Oneform.Add(new OneElementInFormula(0,"с",-1)); f.Oneform.Add(new OneElementInFormula(0, "с", -1)); Dict.AllFormulas.Add(f); var v=new MeterPerSecond(60); var t1=new Seconds(2); var t2=new Seconds(3); var q = v/t1/t2; Console.WriteLine(q.Value+" "+q.Measure); }
protected RetryStrategy(Times maxAttempts, Seconds initialDelay, Seconds delay) { InitialDelay = initialDelay; Delay = delay; counter = new Counter(maxAttempts.Count); }