public static bool TryParse(string version, out IVersionSpecification specification)
        {
            if (!VersionStringHelpers.IsVersionWellFormed(version))
            {
                specification = null;
                return(false);
            }

            specification = new ExactVersionSpecification(version);
            return(true);
        }
        public static bool TryParse(string range, out IVersionSpecification specification)
        {
            bool startInclusive = false;
            bool endInclusive   = false;

            if (range.StartsWith("["))
            {
                startInclusive = true;
            }
            else if (!range.StartsWith("("))
            {
                specification = null;
                return(false);
            }

            if (range.EndsWith("]"))
            {
                endInclusive = true;
            }
            else if (!range.EndsWith(")"))
            {
                specification = null;
                return(false);
            }

            string[] parts = range.Split('-');
            if (parts.Length != 2)
            {
                specification = null;
                return(false);
            }

            string startVersion = parts[0].Substring(1);
            string endVersion   = parts[1].Substring(0, parts[1].Length - 1);

            if (IsWildcardVersion(startVersion) && IsWildcardVersion(endVersion))
            {
                specification = null;
                return(false);
            }
            else if (!IsWildcardVersion(startVersion) && !VersionStringHelpers.IsVersionWellFormed(startVersion))
            {
                specification = null;
                return(false);
            }
            else if (!IsWildcardVersion(endVersion) && !VersionStringHelpers.IsVersionWellFormed(endVersion))
            {
                specification = null;
                return(false);
            }

            specification = new RangeVersionSpecification(startVersion, endVersion, startInclusive, endInclusive);
            return(true);
        }
        public bool CheckIfVersionIsValid(string versionToCheck)
        {
            bool isStartValid;
            bool isEndValid;

            if (!IsWildcardVersion(MinVersion))
            {
                int?startComparison = VersionStringHelpers.CompareVersions(MinVersion, versionToCheck);

                if (startComparison == null)
                {
                    return(false);
                }

                if (IsStartInclusive)
                {
                    isStartValid = startComparison.Value <= 0;
                }
                else
                {
                    isStartValid = startComparison.Value < 0;
                }
            }
            else
            {
                isStartValid = true;
            }

            if (!IsWildcardVersion(MaxVersion))
            {
                int?endComparison = VersionStringHelpers.CompareVersions(versionToCheck, MaxVersion);

                if (endComparison == null)
                {
                    return(false);
                }

                if (IsEndInclusive)
                {
                    isEndValid = endComparison.Value <= 0;
                }
                else
                {
                    isEndValid = endComparison.Value < 0;
                }
            }
            else
            {
                isEndValid = true;
            }

            return(isStartValid && isEndValid);
        }
        public bool CheckIfVersionIsValid(string versionToCheck)
        {
            int?result = VersionStringHelpers.CompareVersions(RequiredVersion, versionToCheck);

            return(result.HasValue && result.Value == 0);
        }