Skip to content

Commit b094ed2

Browse files
committed
Implemented TryParseVersion in PlatformDetectorBase Classes
1 parent b753d05 commit b094ed2

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

MCPForUnity/Editor/Dependencies/PlatformDetectors/PlatformDetectorBase.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,5 +265,36 @@ protected bool TryExecuteProcess(string fileName, string arguments, int timeoutM
265265
return false;
266266
}
267267
}
268+
protected bool TryParseVersion(string versionString, out int major, out int minor)
269+
{
270+
major = 0;
271+
minor = 0;
272+
if (string.IsNullOrEmpty(versionString)) return false;
273+
274+
try
275+
{
276+
var parts = versionString.Split('.');
277+
if (parts.Length >= 2)
278+
{
279+
if (int.TryParse(parts[0], out major) && int.TryParse(parts[1], out minor))
280+
{
281+
return true;
282+
}
283+
}
284+
else if (parts.Length == 1)
285+
{
286+
if (int.TryParse(parts[0], out major))
287+
{
288+
minor = 0;
289+
return true;
290+
}
291+
}
292+
}
293+
catch
294+
{
295+
// Ignore parsing errors
296+
}
297+
return false;
298+
}
268299
}
269300
}

0 commit comments

Comments
 (0)