/// <summary> /// Create a new electric vehicle contract identification. /// </summary> /// <param name="InternalId">The internal representation of the EVCO identification, as there are some many optional characters.</param> /// <param name="ProviderId">The unique identification of an e-mobility provider.</param> /// <param name="Suffix">The suffix of the electric vehicle contract identification.</param> /// <param name="CheckDigit">An optional check digit of the electric vehicle contract identification.</param> private EVCO_Id(String InternalId, Provider_Id ProviderId, String Suffix, Char?CheckDigit = null) { this.InternalId = InternalId; this.ProviderId = ProviderId; this.Suffix = Suffix; this.CheckDigit = CheckDigit; }
/// <summary> /// Parse the given electric vehicle contract identification. /// </summary> /// <param name="ProviderId">The unique identification of an e-mobility provider.</param> /// <param name="Suffix">The suffix of the electric vehicle contract identification.</param> public static EVCO_Id Parse(Provider_Id ProviderId, String Suffix) { #region Initial checks if (Suffix != null) { Suffix = Suffix.Trim(); } if (Suffix.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(Suffix), "The given electric vehicle contract 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> /// Try to parse the given string as an electric vehicle contract identification. /// </summary> /// <param name="Text">A text-representation of an electric vehicle contract identification.</param> /// <param name="EVCOId">The parsed electric vehicle contract identification.</param> public static Boolean TryParse(String Text, out EVCO_Id EVCOId) { #region Initial checks if (Text != null) { Text = Text.Trim(); } if (Text.IsNullOrEmpty()) { EVCOId = default; return(false); } #endregion try { var matchCollection = EVCOId_RegEx.Matches(Text); if (matchCollection.Count != 1) { EVCOId = default; return(false); } // ISO: DE-GDF-C12022187-X, DEGDFC12022187X if (Provider_Id.TryParse(matchCollection[0].Groups[1].Value, out Provider_Id providerId)) { EVCOId = new EVCO_Id(Text, providerId, matchCollection[0].Groups[2].Value, matchCollection[0].Groups[3].Value[0]); return(true); } // DIN: DE*GDF*0010LY*3, DE-GDF-0010LY-3, DEGDF0010LY3 if (Provider_Id.TryParse(matchCollection[0].Groups[4].Value, out providerId)) { if (providerId.Format == ProviderIdFormats.ISO_HYPHEN) { providerId = providerId.ChangeFormat(ProviderIdFormats.DIN_HYPHEN); } EVCOId = new EVCO_Id(Text, providerId.ChangeFormat(ProviderIdFormats.DIN_HYPHEN), matchCollection[0].Groups[5].Value, matchCollection[0].Groups[6].Value[0]); return(true); } } catch (Exception) { EVCOId = default; return(false); } EVCOId = default; return(false); }
/// <summary> /// Create a new OICP provider authentication data record. /// </summary> /// <param name="ProviderId">The unique identification of an Electric Vehicle Service Provider.</param> /// <param name="AuthorizationIdentifications">An enumeration of authorization identifications records.</param> public ProviderAuthenticationData(Provider_Id ProviderId, IEnumerable <Identification> AuthorizationIdentifications) { this.ProviderId = ProviderId; this.AuthorizationIdentifications = AuthorizationIdentifications ?? new Identification[0]; }