using System; using System.Collections.Generic; using System.Text; namespace Wayne.ForecourtControl { /// /// A collection representing the allowed fuel grade maximum volume, that should be used within the authorize parameters. /// public sealed class FuelGradeMaxVolumes : Wayne.ForecourtControl.IFuelGradeMaxVolumes { #region Fields decimal?[] maxVolumes = new decimal?[Defines.MaxFuelGradeCount]; #endregion #region Construction /// /// Internal constructor prohibits creation of this class outside the assembly. /// internal FuelGradeMaxVolumes() { } #endregion #region Indexer /// /// Indexer returning the maximum volume allowed for the fuel grade. /// /// Fuel grade /// Thrown if the fuel grade is out of range. public decimal? this[int index] { get { EvaluateIndex(index); return maxVolumes[index]; } set { EvaluateIndex(index); maxVolumes[index] = value; } } #endregion #region Methods private void EvaluateIndex(int index) { if ((index < 0) || (index >= maxVolumes.Length)) throw new FuelGradeOutOfRangeException(index.ToString(System.Globalization.CultureInfo.InvariantCulture) + " is out of range for fuel grades"); } #endregion #region Properties /// /// Indicates the number of fuel grades. /// public int Count { get { return maxVolumes.Length; } } #endregion } }