コード例 #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 PppmVersion semversion)
        {
            var res = PppmVersion.TryParse(Version, out semversion);

            if (!res && IsLatest)
            {
                semversion = new PppmVersion(int.MaxValue);
                res        = true;
            }
            return(res);
        }
コード例 #2
0
        /// <summary>
        /// Try parsing a string as <see cref="PppmVersion"/>
        /// </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 PppmVersion version, MissingInferenceDelegate inference = null)
        {
            version = new PppmVersion(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);
        }