123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- #region --------------- Copyright Dresser Wayne Pignone -------------
- /*
- * $Log: /Wrk/Support/ForecourtControl/Wrk/ForecourtControl/AllowedFuelGrades.cs $
- *
- * 2 07-01-05 8:58 roger.månsson
- * Moved out fuelgrade out of range exception to separate file. Created an
- * interface for COM.
- */
- #endregion
- namespace Wayne.ForecourtControl
- {
- /// <summary>
- /// A collection representing the allowed fuel grades that should be used within the authrorize parameters.
- /// </summary>
- public sealed class AllowedFuelGrades : Wayne.ForecourtControl.IAllowedFuelGrades
- {
- #region Fields
- bool[] allowedFuelGrades = new bool[Defines.MaxFuelGradeCount];
- #endregion
- #region Construction
- /// <summary>
- /// Internal constructor prohibits creation of this class outside the assembly.
- /// </summary>
- internal AllowedFuelGrades()
- {
- }
- #endregion
- #region Indexer
- /// <summary>
- /// Indexer returning if the fuel grade is allowed.
- /// </summary>
- /// <param name="index">Fuel grade</param>
- /// <returns>True if the fuel grade is allowed, False if it is disallowed.</returns>
- /// <exception cref="FuelGradeOutOfRangeException">Thrown if the fuel grade is out of range.</exception>
- public bool this[int index]
- {
- get
- {
- EvaluateIndex(index);
- return allowedFuelGrades[index];
- }
- set
- {
- EvaluateIndex(index);
- allowedFuelGrades[index] = value;
- }
- }
- #endregion
- #region Methods
- private void EvaluateIndex(int index)
- {
- if ((index < 0) || (index >= allowedFuelGrades.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 allowedFuelGrades.Length;
- }
- }
- #endregion
- }
- }
|