public PartialVersion(string input)
{
string[] xValues = { "X", "x", "*" };
if (input.Trim() == "")
{
// Empty input means any version
return;
}
var match = regex.Match(input);
if (!match.Success)
{
throw new ArgumentException(String.Format("Invalid version string: \"{0}\"", input));
}
if (xValues.Contains(match.Groups[1].Value))
{
Major = null;
}
else
{
Major = Int32.Parse(match.Groups[1].Value);
}
if (match.Groups[2].Success)
{
if (xValues.Contains(match.Groups[3].Value))
{
Minor = null;
}
else
{
Minor = Int32.Parse(match.Groups[3].Value);
}
}
if (match.Groups[4].Success)
{
if (xValues.Contains(match.Groups[5].Value))
{
Patch = null;
}
else
{
Patch = Int32.Parse(match.Groups[5].Value);
}
}
if (match.Groups[6].Success)
{
PreRelease = match.Groups[7].Value;
}
}