/// <summary> /// Indexer to get a registered ChronoMeasures instance. /// <exception cref="ArgumentOutOfRangeException"></exception> /// </summary> public IChronoMeasures <U_meas> this[ChronoStore id] { get { return(_chronoStore[id]); } }
/// <summary> /// Add a chrono. /// </summary> /// <param name="id">Have to be shorter as possible for efficient lookup.</param> /// <param name="chrono">The chronometer measure.</param> /// <exception cref="ArgumentOutOfRangeException">Entry already exist.</exception> public void RegisterMeasure(ChronoStore id, IChronoMeasures <U_meas> chrono) { if (!_chronoStore.ContainsKey(id)) { _chronoStore.Add(id, chrono); _measuresList.Add(chrono.Measures); } else { throw new ArgumentOutOfRangeException($"Chrono with the same name ({id}) already exist!"); } }
/// <summary> /// Try to get a chronoMeasure instance from its id.\n /// NOTE: Use this method to avoid exception when you know you want to handle null ref in case /// you explicitly not registered any Measures (due to an external activation bool flag). /// </summary> /// <code>measuresChronosAggreg.TryGet(ChronoStore.FirstChrono)?.Stop()</code> /// <param name="id">The identifier of the registered chrono instance.</param> /// <returns>chrono instance if exist or null otherwise.</returns> public IChronoMeasures <U_meas> TryGet(ChronoStore id) { return(_chronoStore.ContainsKey(id) ? _chronoStore[id] : null); }