/// <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="PartnerOperatorId">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 PartnerOperator_Id PartnerOperatorId, PartnerOperatorIdFormats IdFormat = PartnerOperatorIdFormats.eMI3_STAR) { #region Initial checks if (CountryCode == null || Suffix.IsNullOrEmpty() || Suffix.Trim().IsNullOrEmpty()) { PartnerOperatorId = default; return(false); } #endregion switch (IdFormat) { case PartnerOperatorIdFormats.eMI3: return(TryParse(CountryCode.Alpha2Code + Suffix, out PartnerOperatorId)); default: return(TryParse(CountryCode.Alpha2Code + "*" + Suffix, out PartnerOperatorId)); } }
/// <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 PartnerOperator_Id Parse(Country CountryCode, String Suffix, PartnerOperatorIdFormats IdFormat = PartnerOperatorIdFormats.eMI3_STAR) { #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 PartnerOperatorIdFormats.eMI3: return(Parse(CountryCode.Alpha2Code + Suffix)); default: return(Parse(CountryCode.Alpha2Code + "*" + Suffix)); } }
/// <summary> /// Create a new charging partner operator identification. /// </summary> /// <param name="CountryCode">The country code.</param> /// <param name="Suffix">The suffix of the charging partner operator identification.</param> /// <param name="Format">The format of the charging partner operator identification.</param> private PartnerOperator_Id(Country CountryCode, String Suffix, PartnerOperatorIdFormats Format = PartnerOperatorIdFormats.eMI3_STAR) { 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 PartnerOperator_Id?TryParse(Country CountryCode, String Suffix, PartnerOperatorIdFormats IdFormat = PartnerOperatorIdFormats.eMI3_STAR) { if (TryParse(CountryCode, Suffix, out PartnerOperator_Id _PartnerOperatorId, IdFormat)) { return(_PartnerOperatorId); } return(new PartnerOperator_Id?()); }
/// <summary> /// Return a text representation of the given operator identification format. /// </summary> /// <param name="PartnerOperatorIdFormat">A operator identification format.</param> public static String AsText(this PartnerOperatorIdFormats PartnerOperatorIdFormat) { switch (PartnerOperatorIdFormat) { case PartnerOperatorIdFormats.eMI3: case PartnerOperatorIdFormats.eMI3_STAR: return("eMI3"); default: return("Gireve"); } }
/// <summary> /// Return a new charging operator identification in the given format. /// </summary> /// <param name="NewFormat">The new charging operator identification format.</param> public PartnerOperator_Id ChangeFormat(PartnerOperatorIdFormats NewFormat) => new PartnerOperator_Id(CountryCode, Suffix, NewFormat);