/// <summary> /// Generate a new e-mobility station identification /// based on the given string. /// </summary> private eMobilityStation_Id(eMobilityProvider_Id ProviderId, String Suffix) { #region Initial checks if (ProviderId == null) { throw new ArgumentNullException(nameof(ProviderId), "The unique provider identification must not be null!"); } if (Suffix.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(Suffix), "The suffix must not be null or empty!"); } #endregion var _MatchCollection = Regex.Matches(Suffix.Trim().ToUpper(), IdSuffix_RegEx, RegexOptions.IgnorePatternWhitespace); if (_MatchCollection.Count != 1) { throw new ArgumentException("Illegal e-mobility station identification suffix '" + Suffix + "'!", nameof(Suffix)); } this.ProviderId = ProviderId; this.Suffix = _MatchCollection[0].Value; }
/// <summary> /// Parse the given electric mobility account identification. /// </summary> /// <param name="ProviderId">The unique identification of an e-mobility provider.</param> /// <param name="Suffix">The suffix of the electric mobility account identification.</param> public static eMobilityAccount_Id Parse(eMobilityProvider_Id ProviderId, String Suffix) { #region Initial checks if (Suffix.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(Suffix), "The given electric mobility account identification suffix must not be null or empty!"); } #endregion switch (ProviderId.Format) { case ProviderIdFormats.DIN: return(Parse(ProviderId + Suffix)); case ProviderIdFormats.DIN_STAR: return(Parse(ProviderId + "*" + Suffix)); case ProviderIdFormats.DIN_HYPHEN: return(Parse(ProviderId + "-" + Suffix)); case ProviderIdFormats.ISO: return(Parse(ProviderId + Suffix)); default: // ISO_HYPHEN return(Parse(ProviderId + "-" + Suffix)); } }
/// <summary> /// Parse the given string as a charging station identification. /// </summary> /// <param name="ProviderId">The unique identification of an Charging Station Operator.</param> /// <param name="Suffix">A text representation of a charging station identification.</param> public static eMobilityStation_Id Parse(eMobilityProvider_Id ProviderId, String Suffix) { #region Initial checks if (ProviderId == null) { throw new ArgumentNullException(nameof(ProviderId), "The unique provider identification must not be null!"); } if (Suffix.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(Suffix), "The suffix must not be null or empty!"); } #endregion eMobilityStation_Id _eMobilityStationId = null; if (TryParse(ProviderId, Suffix, out _eMobilityStationId)) { return(_eMobilityStationId); } return(null); }
/// <summary> /// An exception thrown whenever a e-mobility provider already exists within the given roaming network. /// </summary> /// <param name="RoamingNetwork">The roaming network.</param> /// <param name="EMobilityProviderId">The e-mobility provider identification.</param> public eMobilityProviderAlreadyExists(RoamingNetwork RoamingNetwork, eMobilityProvider_Id EMobilityProviderId) : base(RoamingNetwork, "The given e-mobility provider identification '" + EMobilityProviderId + "' already exists within the given '" + RoamingNetwork.Id + "' roaming network!") { }
/// <summary> /// Generate a new unique identification of an Electric Vehicle Charging Station (EVCS Id). /// </summary> /// <param name="OperatorId">The unique identification of an Charging Station Operator.</param> /// <param name="Mapper">A delegate to modify the newly generated charging station identification.</param> public static eMobilityStation_Id Random(eMobilityProvider_Id ProviderId, Func <String, String> Mapper = null) { #region Initial checks if (ProviderId == null) { throw new ArgumentNullException(nameof(ProviderId), "The parameter must not be null!"); } #endregion return(new eMobilityStation_Id(ProviderId, Mapper != null ? Mapper(_Random.RandomString(12)) : _Random.RandomString(12))); }
/// <summary> /// Generate a new electric mobility account identification /// based on the given string. /// </summary> /// <param name="ProviderId">The unique identification of an e-mobility provider.</param> /// <param name="Suffix">The suffix of the electric mobility account identification.</param> /// <param name="CheckDigit">An optional check digit of the electric mobility account identification.</param> private eMobilityAccount_Id(eMobilityProvider_Id ProviderId, String Suffix, Char?CheckDigit = null) { #region Initial checks if (Suffix.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(Suffix), "The identification suffix must not be null or empty!"); } #endregion this.ProviderId = ProviderId; this.Suffix = Suffix; this.CheckDigit = CheckDigit; }
/// <summary> /// Parse the given string as a charging station identification (EVCS Id). /// </summary> /// <param name="OperatorId">The unique identification of an Charging Station Operator.</param> /// <param name="Suffix">A text representation of a charging station identification.</param> /// <param name="eMobilityStationId">The parsed charging station identification.</param> public static Boolean TryParse(eMobilityProvider_Id OperatorId, String Suffix, out eMobilityStation_Id eMobilityStationId) { #region Initial checks if (OperatorId == null || Suffix.IsNullOrEmpty()) { eMobilityStationId = null; return(false); } #endregion try { eMobilityStationId = null; var _MatchCollection = Regex.Matches(Suffix.Trim().ToUpper(), IdSuffix_RegEx, RegexOptions.IgnorePatternWhitespace); if (_MatchCollection.Count != 1) { return(false); } eMobilityStationId = new eMobilityStation_Id(OperatorId, _MatchCollection[0].Groups[0].Value); return(true); } catch (Exception e) { } eMobilityStationId = null; return(false); }