FuelGradeMaxVolumes.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace Wayne.ForecourtControl
  5. {
  6. /// <summary>
  7. /// A collection representing the allowed fuel grade maximum volume, that should be used within the authorize parameters.
  8. /// </summary>
  9. public sealed class FuelGradeMaxVolumes : Wayne.ForecourtControl.IFuelGradeMaxVolumes
  10. {
  11. #region Fields
  12. decimal?[] maxVolumes = new decimal?[Defines.MaxFuelGradeCount];
  13. #endregion
  14. #region Construction
  15. /// <summary>
  16. /// Internal constructor prohibits creation of this class outside the assembly.
  17. /// </summary>
  18. internal FuelGradeMaxVolumes()
  19. {
  20. }
  21. #endregion
  22. #region Indexer
  23. /// <summary>
  24. /// Indexer returning the maximum volume allowed for the fuel grade.
  25. /// </summary>
  26. /// <param name="index">Fuel grade</param>
  27. /// <exception cref="FuelGradeOutOfRangeException">Thrown if the fuel grade is out of range.</exception>
  28. public decimal? this[int index]
  29. {
  30. get
  31. {
  32. EvaluateIndex(index);
  33. return maxVolumes[index];
  34. }
  35. set
  36. {
  37. EvaluateIndex(index);
  38. maxVolumes[index] = value;
  39. }
  40. }
  41. #endregion
  42. #region Methods
  43. private void EvaluateIndex(int index)
  44. {
  45. if ((index < 0) || (index >= maxVolumes.Length))
  46. throw new FuelGradeOutOfRangeException(index.ToString(System.Globalization.CultureInfo.InvariantCulture) + " is out of range for fuel grades");
  47. }
  48. #endregion
  49. #region Properties
  50. /// <summary>
  51. /// Indicates the number of fuel grades.
  52. /// </summary>
  53. public int Count
  54. {
  55. get
  56. {
  57. return maxVolumes.Length;
  58. }
  59. }
  60. #endregion
  61. }
  62. }