#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
{
///
/// A collection representing the allowed fuel grades that should be used within the authrorize parameters.
///
public sealed class AllowedFuelGrades : Wayne.ForecourtControl.IAllowedFuelGrades
{
#region Fields
bool[] allowedFuelGrades = new bool[Defines.MaxFuelGradeCount];
#endregion
#region Construction
///
/// Internal constructor prohibits creation of this class outside the assembly.
///
internal AllowedFuelGrades()
{
}
#endregion
#region Indexer
///
/// Indexer returning if the fuel grade is allowed.
///
/// Fuel grade
/// True if the fuel grade is allowed, False if it is disallowed.
/// Thrown if the fuel grade is out of range.
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
///
/// Indicates the number of fuel grades.
///
public int Count
{
get
{
return allowedFuelGrades.Length;
}
}
#endregion
}
}