16 public static Version
ChangeVersion(
this Version version,
string changeStr)
18 string[] subVersions = changeStr.Split(
'.');
40 bool[] changeReset =
new bool[4];
42 for (
int i = 4 - 1; i >= 0; i--)
44 string current = subVersions[i];
46 if (current.StartsWith(
"("))
50 for (; j < current.Length; j++)
52 if (current[j] ==
')')
58 if (j == current.Length)
63 string max = current.Substring(1, j - 1);
67 changeReset[i] =
true;
69 else if (
int.TryParse(max, out
int newMax))
76 wrapValues[i] = newMax;
79 current = current.Remove(0, j + 1);
84 if (versions[i] >= wrapValues[i])
97 case "-" when versions[i] != 0:
103 if (current.ToLower(CultureInfo.InvariantCulture) ==
"x")
107 else if (current.StartsWith(
"{") && current.EndsWith(
"}"))
109 string format = current.Remove(current.Length - 1, 1).Remove(0, 1);
111 string value = DateTime.Now.ToString(format);
113 if (
long.TryParse(value, out
long newValue))
115 versions[i] = (int)(newValue % ushort.MaxValue);
118 else if (
int.TryParse(current, out
int v))
132 versions[1] < 0 ? 0 : versions[1],
133 versions[2] < 0 ? 0 : versions[2],
134 versions[3] < 0 ? 0 : versions[3]
145 private static void ApplyChangeReset(IReadOnlyList<bool> changeReset, IReadOnlyList<int> original, IList<int> versions)
147 for (
int j = 0; j < changeReset.Count; j++)
149 if (!changeReset[j] || versions[j] == original[j])
154 for (
int i = j + 1; i < versions.Count; i++)