1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace Wayne.ForecourtControl
- {
- /// <summary>
- /// A collection representing the allowed fuel grade maximum volume, that should be used within the authorize parameters.
- /// </summary>
- public sealed class FuelGradeMaxVolumes : Wayne.ForecourtControl.IFuelGradeMaxVolumes
- {
- #region Fields
- decimal?[] maxVolumes = new decimal?[Defines.MaxFuelGradeCount];
- #endregion
- #region Construction
- /// <summary>
- /// Internal constructor prohibits creation of this class outside the assembly.
- /// </summary>
- internal FuelGradeMaxVolumes()
- {
- }
- #endregion
- #region Indexer
- /// <summary>
- /// Indexer returning the maximum volume allowed for the fuel grade.
- /// </summary>
- /// <param name="index">Fuel grade</param>
- /// <exception cref="FuelGradeOutOfRangeException">Thrown if the fuel grade is out of range.</exception>
- 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
- /// <summary>
- /// Indicates the number of fuel grades.
- /// </summary>
- public int Count
- {
- get
- {
- return maxVolumes.Length;
- }
- }
- #endregion
- }
- }
|