Exemple #1
0
        /// <summary>
        /// Generate a new Electric Vehicle Charging Pool identification (EVCP Id)
        /// based on the given string.
        /// </summary>
        private ChargingPool_Id(EVSEOperator_Id OperatorId,
                                String Suffix,
                                IdFormatType Format = IdFormatType.NEW)
        {
            #region Initial checks

            if (OperatorId == null)
            {
                throw new ArgumentNullException("OperatorId", "The parameter must not be null!");
            }

            if (Suffix.IsNullOrEmpty())
            {
                throw new ArgumentNullException("IdSuffix", "The parameter 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 charging pool identification suffix '" + Suffix + "'!", "IdSuffix");
            }

            this._OperatorId = OperatorId;
            this._Suffix     = _MatchCollection[0].Value;
            this._Format     = Format;
        }
Exemple #2
0
        /// <summary>
        /// Parse the given string as an EVSE Operator identification.
        /// </summary>
        /// <param name="CountryCode">A country code.</param>
        /// <param name="OperatorId">An EVSE operator identification as a string.</param>
        /// <param name="IdFormat">The format of the EVSE operator identification [old|new].</param>
        public static EVSEOperator_Id Parse(Country CountryCode,
                                            String OperatorId,
                                            IdFormatType IdFormat = IdFormatType.NEW)
        {
            #region Initial checks

            if (CountryCode == null)
            {
                throw new ArgumentException("The parameter must not be null or empty!", "CountryCode");
            }

            if (OperatorId.IsNullOrEmpty())
            {
                throw new ArgumentException("The parameter must not be null or empty!", "OperatorId");
            }

            #endregion

            var _MatchCollection = Regex.Matches(OperatorId.Trim().ToUpper(),
                                                 OperatorId_RegEx,
                                                 RegexOptions.IgnorePatternWhitespace);

            if (_MatchCollection.Count != 1)
            {
                throw new ArgumentException("Illegal EVSE Operator identification '" + CountryCode + " / " + OperatorId + "'!", "OperatorId");
            }

            return(new EVSEOperator_Id(CountryCode, _MatchCollection[0].Value, IdFormat));
        }
Exemple #3
0
        /// <summary>
        /// Generate a new Electric Vehicle Supply Equipment (EVSE) identification
        /// based on the given string.
        /// </summary>
        private EVSE_Id(EVSEOperator_Id OperatorId,
                        String IdSuffix,
                        IdFormatType IdFormat = IdFormatType.NEW)
        {
            #region Initial checks

            if (OperatorId == null)
            {
                throw new ArgumentNullException(nameof(OperatorId), "The parameter must not be null!");
            }

            if (IdSuffix.IsNullOrEmpty())
            {
                throw new ArgumentNullException(nameof(IdSuffix), "The parameter must not be null or empty!");
            }

            #endregion

            var _MatchCollection = Regex.Matches(IdSuffix.Trim().ToUpper(),
                                                 IdSuffix_RegEx,
                                                 RegexOptions.IgnorePatternWhitespace);

            if (_MatchCollection.Count != 1)
            {
                throw new ArgumentException("Illegal EVSE identification '" + OperatorId.ToString() + "' with suffix '" + IdSuffix + "'!");
            }

            this._OperatorId = OperatorId;
            this._Suffix     = _MatchCollection[0].Value;
            this._Format     = IdFormat;
        }
Exemple #4
0
 /// <summary>
 /// Create a new Electric Vehicle Supply Equipment Operator identification.
 /// </summary>
 /// <param name="CountryCode">The Alpha-2-CountryCode.</param>
 /// <param name="OperatorId">The EVSE Operator identification.</param>
 /// <param name="IdFormat">The format of the EVSE operator identification [old|new].</param>
 private EVSEOperator_Id(Country CountryCode,
                         String OperatorId,
                         IdFormatType IdFormat = IdFormatType.NEW)
 {
     this._CountryCode = CountryCode;
     this._OperatorId  = OperatorId;
     this._Format      = IdFormat;
 }
Exemple #5
0
        /// <summary>
        /// Generate a new unique identification of an Electric Vehicle Charging Station (EVCS Id).
        /// </summary>
        /// <param name="OperatorId">The unique identification of an EVSE operator.</param>
        /// <param name="Mapper">A delegate to modify the newly generated charging station identification.</param>
        /// <param name="IdFormat">The (EVSE-)format of the charging station identification [old|new].</param>
        public static ChargingPool_Id Random(EVSEOperator_Id OperatorId,
                                             Func <String, String> Mapper = null,
                                             IdFormatType IdFormat        = IdFormatType.NEW)
        {
            #region Initial checks

            if (OperatorId == null)
            {
                throw new ArgumentException("The parameter must not be null!", "OperatorId");
            }

            #endregion

            return(new ChargingPool_Id(OperatorId,
                                       Mapper != null ? Mapper(_Random.RandomString(12)) : _Random.RandomString(12),
                                       IdFormat));
        }
Exemple #6
0
        /// <summary>
        /// Parse the given string as an EVSE Operator identification.
        /// </summary>
        /// <param name="CountryCode">A country code.</param>
        /// <param name="OperatorId">An EVSE operator identification as a string.</param>
        /// <param name="EVSEOperatorId">The parsed EVSE Operator identification.</param>
        /// <param name="IdFormat">The format of the EVSE operator identification [old|new].</param>
        public static Boolean TryParse(Country CountryCode,
                                       String OperatorId,
                                       out EVSEOperator_Id EVSEOperatorId,
                                       IdFormatType IdFormat = IdFormatType.NEW)
        {
            #region Initial checks

            if (CountryCode == null || OperatorId.IsNullOrEmpty())
            {
                EVSEOperatorId = null;
                return(false);
            }

            #endregion

            try
            {
                var _MatchCollection = Regex.Matches(OperatorId.Trim().ToUpper(),
                                                     OperatorId_RegEx,
                                                     RegexOptions.IgnorePatternWhitespace);

                if (_MatchCollection.Count != 1)
                {
                    EVSEOperatorId = null;
                    return(false);
                }

                EVSEOperatorId = new EVSEOperator_Id(CountryCode, _MatchCollection[0].Value, IdFormat);
                return(true);
            }

            catch (Exception e)
            {
                EVSEOperatorId = null;
                return(false);
            }
        }
Exemple #7
0
 /// <summary>
 /// Return the identification in the given format.
 /// </summary>
 /// <param name="IdFormat">The format.</param>
 public String ToFormat(IdFormatType IdFormat)
 {
     return((IdFormat == IdFormatType.NEW)
                ? String.Concat(_CountryCode.Alpha2Code, "*", _OperatorId)
                : String.Concat("+", _CountryCode.TelefonCode, "*", _OperatorId));
 }
Exemple #8
0
 /// <summary>
 /// Return a new EVSE operator identification in the given format.
 /// </summary>
 /// <param name="Format">An EVSE operator identification format.</param>
 public EVSEOperator_Id ChangeFormat(IdFormatType Format)
 {
     return(new EVSEOperator_Id(this._CountryCode, this._OperatorId, Format));
 }
Exemple #9
0
 /// <summary>
 /// Return the identification in the given format.
 /// </summary>
 /// <param name="IdFormat">The format.</param>
 public String ToFormat(IdFormatType IdFormat)
 {
     return((IdFormat == IdFormatType.NEW)
                ? String.Concat(_OperatorId.ToFormat(IdFormat), "*P", _Suffix)
                : String.Concat(_OperatorId.ToFormat(IdFormat), "*", _Suffix));
 }
Exemple #10
0
        ///// <summary>
        ///// Parse the given string as an EVSE identification.
        ///// </summary>
        //public static Boolean TryParse(EVSEOperator_Id OperatorId, String IdSuffix, out EVSE_Id EVSE_Id)
        //{

        //    try
        //    {
        //        EVSE_Id = new EVSE_Id(OperatorId, IdSuffix);
        //        return true;
        //    }
        //    catch (Exception e)
        //    { }

        //    EVSE_Id = null;
        //    return false;

        //}

        #endregion

        #region ChangeFormat

        /// <summary>
        /// Return a new EVSE identification in the given format.
        /// </summary>
        /// <param name="Format">An EVSE identification format.</param>
        public EVSE_Id ChangeFormat(IdFormatType Format)
        {
            return(new EVSE_Id(this._OperatorId.ChangeFormat(Format), this._Suffix, Format));
        }