Skip to content

Commit d1c6ba8

Browse files
authored
Merge pull request #34 from jwittner/dev/comparableVersions
Implement IComparable on UnityVersion
2 parents 7cbe428 + 209155d commit d1c6ba8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

UnitySetup/UnitySetup.psm1

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class UnityProjectInstance
6969
}
7070
}
7171

72-
class UnityVersion
72+
class UnityVersion : System.IComparable
7373
{
7474
[int] $Major;
7575
[int] $Minor;
@@ -100,6 +100,14 @@ class UnityVersion
100100
}
101101
}
102102

103+
[int] CompareTo([object]$obj)
104+
{
105+
if($null -eq $obj) { return 1 }
106+
if($obj -isnot [UnityVersion]) { throw "Object is not a UnityVersion"}
107+
108+
return [UnityVersion]::Compare($this, $obj)
109+
}
110+
103111
static [int] Compare([UnityVersion]$a, [UnityVersion]$b)
104112
{
105113
if($a.Major -lt $b.Major) { return -1 }

0 commit comments

Comments
 (0)