public static bool TryParsePackage(string name, out PackageFullName info)
        {
            if (name == null)
            {
                info = null;
                return(false);
            }

            var match = _regex.Match(name);

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

            var typeMatch = match.Groups["type"];
            RegistryPackageType type;

            if (!typeMatch.Success)
            {
                type = RegistryPackageType.Scripts;
            }
            else if (!Enum.TryParse(typeMatch.Value, true, out type) || type == RegistryPackageType.Unknown)
            {
                info = null;
                return(false);
            }

            info = new PackageFullName
            {
                Type    = type,
                Name    = match.Groups["name"].Value,
                Version = match.Groups["version"].Success ? match.Groups["version"].Value : null
            };
            return(true);
        }
Beispiel #2
0
 public RegistryPackage GetPackage(PackageFullName packageName)
 {
     return(GetPackage(packageName.Type, packageName.Name));
 }