/// <summary> /// Create a new group of OICP EVSE status records. /// </summary> /// <param name="EVSEStatusRecords">An enumeration of EVSE status records.</param> /// <param name="OperatorId">The unqiue identification of the EVSE operator maintaining the given EVSE status records.</param> /// <param name="OperatorName">An optional name of the EVSE operator maintaining the given EVSE status records.</param> /// <param name="CustomData">An optional dictionary of customer-specific data.</param> public OperatorEVSEStatus(IEnumerable <EVSEStatusRecord> EVSEStatusRecords, Operator_Id OperatorId, String OperatorName = null, IReadOnlyDictionary <String, Object> CustomData = null) : base(CustomData) { #region Initial checks if (EVSEStatusRecords == null || !EVSEStatusRecords.Any()) { throw new ArgumentNullException(nameof(EVSEStatusRecords), "The given enumeration of EVSE status records must not be null or empty!"); } if (OperatorName != null) { OperatorName = OperatorName.Trim(); } #endregion this.EVSEStatusRecords = EVSEStatusRecords; this.OperatorId = OperatorId; this.OperatorName = OperatorName.SubstringMax(100); }
/// <summary> /// Parse the given string as an EVSE identification. /// </summary> /// <param name="OperatorId">The unique identification of a charging station operator.</param> /// <param name="Suffix">The suffix of the EVSE identification.</param> public static EVSE_Id Parse(Operator_Id OperatorId, String Suffix) { #region Initial checks if (Suffix != null) { Suffix = Suffix.Trim(); } if (Suffix.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(Suffix), "The given text-representation of an EVSE identification suffix must not be null or empty!"); } #endregion switch (OperatorId.Format) { case OperatorIdFormats.DIN: return(Parse(OperatorId + "*" + Suffix)); case OperatorIdFormats.ISO: return(Parse(OperatorId + "E" + Suffix)); default: // ISO_STAR return(Parse(OperatorId + "*E" + Suffix)); } }
/// <summary> /// Try to parse the given string as an EVSE identification. /// </summary> /// <param name="Text">A text-representation of an EVSE identification.</param> /// <param name="EVSEId">The parsed EVSE identification.</param> public static Boolean TryParse(String Text, out EVSE_Id EVSEId) { #region Initial checks if (Text != null) { Text = Text.Trim(); } if (Text.IsNullOrEmpty()) { EVSEId = default(EVSE_Id); return(false); } #endregion try { var MatchCollection = EVSEId_RegEx.Matches(Text.Trim().ToUpper()); if (MatchCollection.Count == 1) { Operator_Id _EVSEOperatorId; // New format... if (Operator_Id.TryParse(MatchCollection[0].Groups[1].Value, out _EVSEOperatorId)) { EVSEId = new EVSE_Id(_EVSEOperatorId, MatchCollection[0].Groups[2].Value); return(true); } // Old format... if (Operator_Id.TryParse(MatchCollection[0].Groups[3].Value, out _EVSEOperatorId)) { EVSEId = new EVSE_Id(_EVSEOperatorId, MatchCollection[0].Groups[4].Value); return(true); } } } #pragma warning disable RCS1075 // Avoid empty catch clause that catches System.Exception. #pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body catch (Exception) { } #pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body #pragma warning restore RCS1075 // Avoid empty catch clause that catches System.Exception. EVSEId = default(EVSE_Id); return(false); }
/// <summary> /// Generate a new Electric Vehicle Supply Equipment (EVSE) identification /// based on the given charging station operator and identification suffix. /// </summary> /// <param name="OperatorId">The unique identification of a charging station operator.</param> /// <param name="Suffix">The suffix of the EVSE identification.</param> private EVSE_Id(Operator_Id OperatorId, String Suffix) { #region Initial checks if (Suffix.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(Suffix), "The EVSE identification suffix must not be null or empty!"); } #endregion this.OperatorId = OperatorId; this.Suffix = Suffix; }
/// <summary> /// Parse the given string as an EVSE identification. /// </summary> /// <param name="Text">A text-representation of an EVSE identification.</param> public static EVSE_Id Parse(String Text) { #region Initial checks if (Text != null) { Text = Text.Trim(); } if (Text.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(Text), "The given text-representation of an EVSE identification must not be null or empty!"); } #endregion var MatchCollection = EVSEId_RegEx.Matches(Text); if (MatchCollection.Count != 1) { throw new ArgumentException("Illegal EVSE identification '" + Text + "'!", nameof(Text)); } Operator_Id _OperatorId; if (Operator_Id.TryParse(MatchCollection[0].Groups[1].Value, out _OperatorId)) { return(new EVSE_Id(_OperatorId, MatchCollection[0].Groups[2].Value)); } if (Operator_Id.TryParse(MatchCollection[0].Groups[3].Value, out _OperatorId)) { return(new EVSE_Id(_OperatorId, MatchCollection[0].Groups[4].Value)); } throw new ArgumentException("Illegal EVSE identification '" + Text + "'!", nameof(Text)); }