Exemplo n.º 1
0
        /// <summary>
        /// Is the versioning of referred pack semantical?
        /// </summary>
        /// <param name="semversion">Parsed version</param>
        /// <returns>True if semantical</returns>
        public bool IsSemanticalVersion(out UppmVersion semversion)
        {
            var res = UppmVersion.TryParse(Version, out semversion);

            if (!res && IsLatest)
            {
                semversion = new UppmVersion(int.MaxValue);
                res        = true;
            }
            return(res);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Try parsing a string as <see cref="UppmVersion"/>
        /// </summary>
        /// <param name="input">Input string</param>
        /// <param name="version">Output version if successful, 0 Major if not</param>
        /// <param name="inference">Missing semantic component inference method</param>
        /// <returns>Whether parsing was successful or not</returns>
        public static bool TryParse(string input, out UppmVersion version, MissingInferenceDelegate inference = null)
        {
            version = new UppmVersion(0, inference: inference);
            var regex = Regex.Match(input.Trim(), @"^(?<major>\d+?)(\.|$)(?<minor>\d+?)?(\.|$)(?<build>\d+?)?(\.|$)(?<rev>\d+?)?$");

            if (!regex.Success)
            {
                return(false);
            }
            version.Major    = int.TryParse(regex.Groups["major"].Value, out var major) ? major : 0;
            version.Minor    = int.TryParse(regex.Groups["minor"].Value, out var minor) ? new int?(minor) : null;
            version.Build    = int.TryParse(regex.Groups["build"].Value, out var build) ? new int?(build) : null;
            version.Revision = int.TryParse(regex.Groups["rev"].Value, out var rev) ? new int?(rev) : null;
            return(true);
        }