示例#1
0
        /// <summary>
        /// Parse the given string as an Electric Mobility Account (driver contract) (eMA_Id).
        /// </summary>
        /// <param name="Text">A text representation of an Electric Mobility Account (driver contract) identification.</param>
        /// <param name="eMAId">The parsed Electric Mobility Account (driver contract) identification.</param>
        public static Boolean TryParse(String Text, out eMA_Id eMAId)
        {
            #region Initial checks

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

            eMAId = null;

            #endregion

            var _MatchCollection = Regex.Matches(Text.Trim().ToUpper(),
                                                 eMAId_RegEx,
                                                 RegexOptions.IgnorePatternWhitespace);

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

            EVSP_Id __ProviderId = null;

            if (EVSP_Id.TryParse(_MatchCollection[0].Groups[1].Value, out __ProviderId))
            {
                eMAId = new eMA_Id(__ProviderId.ToString() + "*" + _MatchCollection[0].Groups[6].Value + "*" + _MatchCollection[0].Groups[8].Value);
                return(true);
            }

            return(false);
        }
示例#2
0
        /// <summary>
        /// Parse the given string as an Electric Mobility Account (driver contract) (eMA_Id).
        /// </summary>
        /// <param name="Text">A text representation of an Electric Mobility Account (driver contract) identification.</param>
        public static eMA_Id Parse(String Text)
        {
            #region Initial checks

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

            #endregion

            var _MatchCollection = Regex.Matches(Text.Trim().ToUpper(),
                                                 eMAId_RegEx,
                                                 RegexOptions.IgnorePatternWhitespace);

            if (_MatchCollection.Count != 1)
            {
                throw new ArgumentException("The given string can not be parsed as eMA identification!", nameof(Text));
            }

            EVSP_Id __ProviderId = null;

            if (EVSP_Id.TryParse(_MatchCollection[0].Groups[1].Value, out __ProviderId))
            {
                return(new eMA_Id(__ProviderId.ToString() + "*" + _MatchCollection[0].Groups[6].Value + "*" + _MatchCollection[0].Groups[8].Value));
            }

            throw new ArgumentException("The given string can not be parsed as eMA identification!", nameof(Text));
        }