/// <summary> /// Try to parse the given text representation of an e-mobility operator identification. /// </summary> /// <param name="CountryCode">A country code.</param> /// <param name="Suffix">The suffix of an e-mobility operator identification.</param> /// <param name="PartnerId">The parsed e-mobility operator identification.</param> /// <param name="IdFormat">The optional format of the e-mobility operator identification.</param> public static Boolean TryParse(Country CountryCode, String Suffix, out Partner_Id PartnerId, PartnerIdFormats IdFormat = PartnerIdFormats.eMI3_STAR) { #region Initial checks if (CountryCode == null || Suffix.IsNullOrEmpty() || Suffix.Trim().IsNullOrEmpty()) { PartnerId = default(Partner_Id); return(false); } #endregion switch (IdFormat) { case PartnerIdFormats.eMI3: return(TryParse(CountryCode.Alpha2Code + Suffix, out PartnerId)); default:_STAR: return(TryParse(CountryCode.Alpha2Code + "*" + Suffix, out PartnerId)); } }
/// <summary> /// Parse the given string as an charging operator identification. /// </summary> /// <param name="CountryCode">A country code.</param> /// <param name="Suffix">The suffix of an charging operator identification.</param> /// <param name="IdFormat">The format of the charging operator identification [old|new].</param> public static Partner_Id Parse(Country CountryCode, String Suffix, PartnerIdFormats IdFormat = PartnerIdFormats.eMI3) { #region Initial checks if (CountryCode == null) { throw new ArgumentNullException(nameof(CountryCode), "The given country must not be null!"); } if (Suffix.IsNullOrEmpty()) { throw new ArgumentNullException(nameof(Suffix), "The given charging operator identification suffix must not be null or empty!"); } #endregion switch (IdFormat) { case PartnerIdFormats.eMI3: return(Parse(CountryCode.Alpha2Code + Suffix)); default: return(Parse(CountryCode.Alpha2Code + "*" + Suffix)); } }
/// <summary> /// Create a new charging operator identification. /// </summary> /// <param name="CountryCode">The country code.</param> /// <param name="Suffix">The suffix of the charging operator identification.</param> /// <param name="Format">The format of the charging operator identification.</param> private Partner_Id(Country CountryCode, String Suffix, PartnerIdFormats Format = PartnerIdFormats.eMI3) { this.CountryCode = CountryCode; this.Suffix = Suffix; this.Format = Format; }
/// <summary> /// Try to parse the given text representation of an e-mobility operator identification. /// </summary> /// <param name="CountryCode">A country code.</param> /// <param name="Suffix">The suffix of an e-mobility operator identification.</param> /// <param name="IdFormat">The optional format of the e-mobility operator identification.</param> public static Partner_Id?TryParse(Country CountryCode, String Suffix, PartnerIdFormats IdFormat = PartnerIdFormats.eMI3_STAR) { if (TryParse(CountryCode, Suffix, out Partner_Id _PartnerId, IdFormat)) { return(_PartnerId); } return(new Partner_Id?()); }
/// <summary> /// Return a text representation of the given partner identification format. /// </summary> /// <param name="PartnerIdFormat">A partner identification format.</param> public static String AsText(this PartnerIdFormats PartnerIdFormat) { switch (PartnerIdFormat) { case PartnerIdFormats.eMI3: return("eMI3"); case PartnerIdFormats.eMI3_STAR: return("eMI3"); default: return("Gireve"); } }
/// <summary> /// Return the identification in the given format. /// </summary> /// <param name="Format">The format of the identification.</param> public String ToString(PartnerIdFormats Format) { switch (Format) { case PartnerIdFormats.eMI3: return(String.Concat(CountryCode.Alpha2Code, Suffix)); case PartnerIdFormats.eMI3_STAR: return(String.Concat(CountryCode.Alpha2Code, "*", Suffix)); default: // DIN return(String.Concat("+", CountryCode.TelefonCode, "*", Suffix)); } }
/// <summary> /// Return a new charging operator identification in the given format. /// </summary> /// <param name="NewFormat">The new charging operator identification format.</param> public Partner_Id ChangeFormat(PartnerIdFormats NewFormat) => new Partner_Id(CountryCode, Suffix, NewFormat);