/// <summary> /// Add an occurrence /// </summary> /// <param name="occurrence"></param> public void AddOccurrence(Occurrence occurrence) { if (IsSetupFinalised) { throw new InvalidOperationException("Cannot add occurrences after game setup is finalised"); } Occurrences.Add(occurrence.Name, occurrence); }
private void GetOccurrences(ProdactObject selectedItem) { Occurrences.Clear(); var Structures = AppService.StaticStoredObjs.ObjStructures.ToList().Where(e => e.LinkToObj.ProdactObj == selectedItem); foreach (var str in Structures) { Occurrences.Add(str.ProdactObject); } }
/// <summary> /// Evaluates <see cref="Alarm"/>s for the given recurring component, <paramref name="rc"/>. /// This evaluation is based on the evaluation period for the <see cref="RecurringComponent"/>. /// </summary> /// <param name="rc">The </param> /// <returns></returns> virtual public List <AlarmOccurrence> Evaluate(RecurringComponent rc) { Occurrences.Clear(); // If the trigger is relative, it can recur right along with // the recurring items, otherwise, it happens once and // only once (at a precise time). if (Trigger.IsRelative) { Duration d = null; foreach (Period p in rc.Periods) { Date_Time dt = p.StartTime; if (Trigger.Related == Trigger.TriggerRelation.END) { if (p.EndTime != null) { dt = p.EndTime; if (d == null) { d = p.Duration; } } // Use the "last-found" duration as a reference point else if (d != null) { dt = p.StartTime + d; } else { throw new ArgumentException("Alarm trigger is relative to the END of the occurrence; however, the occurence has no discernible end."); } } Occurrences.Add(new AlarmOccurrence(this, dt + Trigger.Duration, rc)); } } else { Occurrences.Add(new AlarmOccurrence(this, Trigger.DateTime.Copy(), rc)); } // If a REPEAT and DURATION value were specified, // then handle those repetitions here. AddRepeatedItems(); return(Occurrences); }
/// <summary> /// Handles the repetitions that occur from the <c>REPEAT</c> and /// <c>DURATION</c> properties. Each recurrence of the alarm will /// have its own set of generated repetitions. /// </summary> virtual protected void AddRepeatedItems() { if (Repeat != null) { int len = Occurrences.Count; for (int i = 0; i < len; i++) { AlarmOccurrence ao = Occurrences[i]; Date_Time AlarmTime = ao.DateTime.Copy(); for (int j = 0; j < Repeat; j++) { AlarmTime += Duration; Occurrences.Add(new AlarmOccurrence(this, AlarmTime.Copy(), ao.Component)); } } } }
public void CountSpen() { foreach (int lineIndex in Lines) { int occurrencesInLine = 0; Word[] words = Data.Code[lineIndex]; foreach (Word word in words) { if (word.Text == Name.Text) { occurrencesInLine++; Spen++; } } Occurrences.Add(occurrencesInLine); } Spen--; }
/// <summary> /// Registers occurrence of a code smell at a given position. Note: both lines and columns are counted from 1 /// </summary> /// <param name="LineStart">Line at which the occurrence started</param> /// <param name="ColStart">Column at which the occurrence started</param> /// <param name="LineEnd">Line at which the occurrence ended</param> /// <param name="ColEnd">Column at which the occurrence ended</param> public void RegisterOccurrence(int LineStart, int ColStart, int LineEnd, int ColEnd) { Occurrences.Add(new Occurrence { LineStart = LineStart, ColStart = ColStart, LineEnd = LineEnd, ColEnd = ColEnd }); }