예제 #1
0
        /// <summary>
        /// Attempt to convert a string to an equivalent PackageVersionRange.
        /// </summary>
        /// <param name="value">The string to convert.</param>
        /// <param name="range">The converted PackageVersionRange.</param>
        /// <returns>True if the conversion succeeded, false otherwise.</returns>
        public static bool TryParse(string value, out PluginVersionRange range)
        {
            range = default;

            if (string.IsNullOrEmpty(value))
            {
                return(false);
            }

            var match = PackageVersionRangeRegex.Match(value);

            if (!match.Success)
            {
                return(false);
            }

            if (match.Groups["equal"].Success)
            {
                if (!PluginVersion.TryParse(match.Groups["equal"].Value, out var equalVer))
                {
                    return(false);
                }

                range = new PluginVersionRange(equalVer, true, new PluginVersion(equalVer.Major ?? int.MaxValue, equalVer.Minor ?? int.MaxValue, equalVer.Patch ?? int.MaxValue), true);
                return(true);
            }

            var min = default(PluginVersion?);
            var max = default(PluginVersion?);

            if (match.Groups["min"].Success)
            {
                if (!PluginVersion.TryParse(match.Groups["min"].Value, out var minVer))
                {
                    return(false);
                }
                min = minVer;
            }

            if (match.Groups["max"].Success)
            {
                if (!PluginVersion.TryParse(match.Groups["max"].Value, out var maxVer))
                {
                    return(false);
                }
                max = maxVer;
            }

            range = new PluginVersionRange(min, match.Groups["left"].Value == "[", max, match.Groups["right"].Value == "]");
            return(true);
        }
예제 #2
0
 public bool VerifyManifest() => !Name.Intersect(Path.GetInvalidFileNameChars()).Any() &&
 PluginVersion.TryParse(Version, out _) &&
 (Homepage == null || Uri.TryCreate(Homepage, UriKind.Absolute, out _)) &&
 (Update == null || Uri.TryCreate(Update, UriKind.Absolute, out _)) &&
 Files.All(x => x.VerifyFile());