示例#1
0
        public static bool TryParse(string input, out Version result)
        {
            VersionResult r = new VersionResult();

            r.Init("input", false);
            bool b = TryParseVersion(input, ref r);

            result = r.m_parsedVersion;
            return(b);
        }
示例#2
0
        public static bool TryParse(string input, out VersionEx result)
        {
            VersionResult result2 = default(VersionResult);

            result2.Init("input", canThrow: false);
            bool result3 = TryParseVersion(input, ref result2);

            result = result2.m_parsedVersion;
            return(result3);
        }
示例#3
0
        public static bool TryParse(string input, out Version result)
        {
            VersionResult result2 = new VersionResult();

            result2.Init("input", false);
            bool flag = TryParseVersion(input, ref result2);

            result = result2.m_parsedVersion;
            return(flag);
        }
示例#4
0
        /// <summary>
        /// Parse <paramref name="version"/> and return the result if it is a valid <see cref="SemanticVersion"/>, otherwise throws an exception.
        /// </summary>
        /// <param name="version">The string to parse</param>
        /// <returns></returns>
        /// <exception cref="PSArgumentException"></exception>
        /// <exception cref="ValidationMetadataException"></exception>
        /// <exception cref="FormatException"></exception>
        /// <exception cref="OverflowException"></exception>
        public static SemanticVersion Parse(string version)
        {
            if (version == null)
            {
                throw PSTraceSource.NewArgumentNullException(nameof(version));
            }

            var r = new VersionResult();

            r.Init(true);
            TryParseVersion(version, ref r);

            return(r._parsedVersion);
        }
示例#5
0
        public static Version Parse(string input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }
            VersionResult result = new VersionResult();

            result.Init("input", true);
            if (!TryParseVersion(input, ref result))
            {
                throw result.GetVersionParseException();
            }
            return(result.m_parsedVersion);
        }
示例#6
0
        public static Version Parse(string input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }
            Contract.EndContractBlock();

            VersionResult r = new VersionResult();

            r.Init("input", true);
            if (!TryParseVersion(input, ref r))
            {
                throw r.GetVersionParseException();
            }
            return(r.m_parsedVersion);
        }
示例#7
0
        /// <summary>
        /// Parse <paramref name="version"/> and return true if it is a valid <see cref="SemanticVersion"/>, otherwise return false.
        /// No exceptions are raised.
        /// </summary>
        /// <param name="version">The string to parse</param>
        /// <param name="result">The return value when the string is a valid <see cref="SemanticVersion"/></param>
        public static bool TryParse(string version, out SemanticVersion result)
        {
            if (version != null)
            {
                var r = new VersionResult();
                r.Init(false);

                if (TryParseVersion(version, ref r))
                {
                    result = r._parsedVersion;
                    return(true);
                }
            }

            result = null;
            return(false);
        }
        /// <summary>
        /// Parse <paramref name="version"/> and return the result if it is a valid <see cref="SemanticVersion"/>, otherwise throws an exception.
        /// </summary>
        /// <param name="version">The string to parse.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="FormatException"></exception>
        /// <exception cref="OverflowException"></exception>
        public static SemanticVersion Parse(string version)
        {
            if (version == null)
            {
                throw new ArgumentNullException(nameof(version));
            }
            if (version == string.Empty)
            {
                throw new FormatException(nameof(version));
            }

            var r = new VersionResult();

            r.Init(true);
            TryParseVersion(version, ref r);

            return(r._parsedVersion);
        }