|
| 1 | +// |
| 2 | +// AppleSdkVersion.cs |
| 3 | +// |
| 4 | +// Authors: Michael Hutchinson <mhutchinson@novell.com> |
| 5 | +// Jeffrey Stedfast <jeff@xamarin.com> |
| 6 | +// |
| 7 | +// Copyright (c) 2010 Novell, Inc. (http://www.novell.com) |
| 8 | +// Copyright (c) 2011-2013 Xamarin Inc. (http://www.xamarin.com) |
| 9 | +// Copyright (c) 2021 Microsoft Corp. (http://www.microsoft.com) |
| 10 | +// |
| 11 | +// Permission is hereby granted, free of charge, to any person obtaining a copy |
| 12 | +// of this software and associated documentation files (the "Software"), to deal |
| 13 | +// in the Software without restriction, including without limitation the rights |
| 14 | +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 15 | +// copies of the Software, and to permit persons to whom the Software is |
| 16 | +// furnished to do so, subject to the following conditions: |
| 17 | +// |
| 18 | +// The above copyright notice and this permission notice shall be included in |
| 19 | +// all copies or substantial portions of the Software. |
| 20 | +// |
| 21 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 22 | +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 23 | +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 24 | +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 25 | +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 26 | +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 27 | +// THE SOFTWARE. |
| 28 | + |
| 29 | +using System; |
| 30 | + |
| 31 | +namespace Xamarin.MacDev { |
| 32 | + public struct AppleSdkVersion : IComparable<AppleSdkVersion>, IEquatable<AppleSdkVersion>, IAppleSdkVersion { |
| 33 | + int [] version; |
| 34 | + |
| 35 | + public AppleSdkVersion (Version version) |
| 36 | + { |
| 37 | + if (version == null) |
| 38 | + throw new ArgumentNullException (); |
| 39 | + |
| 40 | + if (version.Build != -1) { |
| 41 | + this.version = new int [3]; |
| 42 | + this.version [2] = version.Build; |
| 43 | + } else { |
| 44 | + this.version = new int [2]; |
| 45 | + } |
| 46 | + |
| 47 | + this.version [0] = version.Major; |
| 48 | + this.version [1] = version.Minor; |
| 49 | + } |
| 50 | + |
| 51 | + public AppleSdkVersion (params int [] version) |
| 52 | + { |
| 53 | + if (version == null) |
| 54 | + throw new ArgumentNullException (nameof (version)); |
| 55 | + |
| 56 | + this.version = version; |
| 57 | + } |
| 58 | + |
| 59 | + void IAppleSdkVersion.SetVersion (int [] version) |
| 60 | + { |
| 61 | + this.version = version; |
| 62 | + } |
| 63 | + |
| 64 | + public static AppleSdkVersion Parse (string s) |
| 65 | + { |
| 66 | + return IAppleSdkVersion_Extensions.Parse<AppleSdkVersion> (s); |
| 67 | + } |
| 68 | + |
| 69 | + public static bool TryParse (string s, out AppleSdkVersion result) |
| 70 | + { |
| 71 | + return IAppleSdkVersion_Extensions.TryParse (s, out result); |
| 72 | + } |
| 73 | + |
| 74 | + public int [] Version { get { return version; } } |
| 75 | + |
| 76 | + public override string ToString () |
| 77 | + { |
| 78 | + return IAppleSdkVersion_Extensions.ToString (this); |
| 79 | + } |
| 80 | + |
| 81 | + public int CompareTo (AppleSdkVersion other) |
| 82 | + { |
| 83 | + return IAppleSdkVersion_Extensions.CompareTo (this, other); |
| 84 | + } |
| 85 | + |
| 86 | + public int CompareTo (IAppleSdkVersion other) |
| 87 | + { |
| 88 | + return IAppleSdkVersion_Extensions.CompareTo (this, other); |
| 89 | + } |
| 90 | + |
| 91 | + public bool Equals (IAppleSdkVersion other) |
| 92 | + { |
| 93 | + return IAppleSdkVersion_Extensions.Equals (this, other); |
| 94 | + } |
| 95 | + |
| 96 | + public bool Equals (AppleSdkVersion other) |
| 97 | + { |
| 98 | + return IAppleSdkVersion_Extensions.Equals (this, other); |
| 99 | + } |
| 100 | + |
| 101 | + public override bool Equals (object obj) |
| 102 | + { |
| 103 | + return IAppleSdkVersion_Extensions.Equals (this, obj); |
| 104 | + } |
| 105 | + |
| 106 | + public override int GetHashCode () |
| 107 | + { |
| 108 | + return IAppleSdkVersion_Extensions.GetHashCode (this); |
| 109 | + } |
| 110 | + |
| 111 | + public static bool operator == (AppleSdkVersion a, IAppleSdkVersion b) |
| 112 | + { |
| 113 | + return a.Equals (b); |
| 114 | + } |
| 115 | + |
| 116 | + public static bool operator != (AppleSdkVersion a, IAppleSdkVersion b) |
| 117 | + { |
| 118 | + return !a.Equals (b); |
| 119 | + } |
| 120 | + |
| 121 | + public static bool operator < (AppleSdkVersion a, IAppleSdkVersion b) |
| 122 | + { |
| 123 | + return a.CompareTo (b) < 0; |
| 124 | + } |
| 125 | + |
| 126 | + public static bool operator > (AppleSdkVersion a, IAppleSdkVersion b) |
| 127 | + { |
| 128 | + return a.CompareTo (b) > 0; |
| 129 | + } |
| 130 | + |
| 131 | + public static bool operator <= (AppleSdkVersion a, IAppleSdkVersion b) |
| 132 | + { |
| 133 | + return a.CompareTo (b) <= 0; |
| 134 | + } |
| 135 | + |
| 136 | + public static bool operator >= (AppleSdkVersion a, IAppleSdkVersion b) |
| 137 | + { |
| 138 | + return a.CompareTo (b) >= 0; |
| 139 | + } |
| 140 | + |
| 141 | + public bool IsUseDefault { |
| 142 | + get { return version == null || version.Length == 0; } |
| 143 | + } |
| 144 | + |
| 145 | + IAppleSdkVersion IAppleSdkVersion.GetUseDefault () |
| 146 | + { |
| 147 | + return UseDefault; |
| 148 | + } |
| 149 | + |
| 150 | +#if !WINDOWS |
| 151 | + public AppleSdkVersion ResolveIfDefault (AppleSdk sdk, bool sim) |
| 152 | + { |
| 153 | + return IsUseDefault ? GetDefault (sdk, sim) : this; |
| 154 | + } |
| 155 | + |
| 156 | + public static AppleSdkVersion GetDefault (AppleSdk sdk, bool sim) |
| 157 | + { |
| 158 | + var v = sdk.GetInstalledSdkVersions (sim); |
| 159 | + return v.Count > 0 ? v [v.Count - 1] : UseDefault; |
| 160 | + } |
| 161 | +#endif |
| 162 | + |
| 163 | + public static readonly AppleSdkVersion UseDefault = new AppleSdkVersion (new int [0]); |
| 164 | + |
| 165 | + public static readonly AppleSdkVersion V1_0 = new AppleSdkVersion (1, 0); |
| 166 | + public static readonly AppleSdkVersion V2_0 = new AppleSdkVersion (2, 0); |
| 167 | + public static readonly AppleSdkVersion V2_1 = new AppleSdkVersion (2, 1); |
| 168 | + public static readonly AppleSdkVersion V2_2 = new AppleSdkVersion (2, 2); |
| 169 | + public static readonly AppleSdkVersion V3_0 = new AppleSdkVersion (3, 0); |
| 170 | + public static readonly AppleSdkVersion V3_1 = new AppleSdkVersion (3, 1); |
| 171 | + public static readonly AppleSdkVersion V3_2 = new AppleSdkVersion (3, 2); |
| 172 | + public static readonly AppleSdkVersion V3_99 = new AppleSdkVersion (3, 99); |
| 173 | + public static readonly AppleSdkVersion V4_0 = new AppleSdkVersion (4, 0); |
| 174 | + public static readonly AppleSdkVersion V4_1 = new AppleSdkVersion (4, 1); |
| 175 | + public static readonly AppleSdkVersion V4_2 = new AppleSdkVersion (4, 2); |
| 176 | + public static readonly AppleSdkVersion V4_3 = new AppleSdkVersion (4, 3); |
| 177 | + public static readonly AppleSdkVersion V5_0 = new AppleSdkVersion (5, 0); |
| 178 | + public static readonly AppleSdkVersion V5_1 = new AppleSdkVersion (5, 1); |
| 179 | + public static readonly AppleSdkVersion V5_1_1 = new AppleSdkVersion (5, 1, 1); |
| 180 | + public static readonly AppleSdkVersion V5_2 = new AppleSdkVersion (5, 2); |
| 181 | + public static readonly AppleSdkVersion V6_0 = new AppleSdkVersion (6, 0); |
| 182 | + public static readonly AppleSdkVersion V6_1 = new AppleSdkVersion (6, 1); |
| 183 | + public static readonly AppleSdkVersion V6_2 = new AppleSdkVersion (6, 2); |
| 184 | + public static readonly AppleSdkVersion V7_0 = new AppleSdkVersion (7, 0); |
| 185 | + public static readonly AppleSdkVersion V7_1 = new AppleSdkVersion (7, 1); |
| 186 | + public static readonly AppleSdkVersion V7_2_1 = new AppleSdkVersion (7, 2, 1); |
| 187 | + public static readonly AppleSdkVersion V8_0 = new AppleSdkVersion (8, 0); |
| 188 | + public static readonly AppleSdkVersion V8_1 = new AppleSdkVersion (8, 1); |
| 189 | + public static readonly AppleSdkVersion V8_2 = new AppleSdkVersion (8, 2); |
| 190 | + public static readonly AppleSdkVersion V8_3 = new AppleSdkVersion (8, 3); |
| 191 | + public static readonly AppleSdkVersion V8_4 = new AppleSdkVersion (8, 4); |
| 192 | + public static readonly AppleSdkVersion V9_0 = new AppleSdkVersion (9, 0); |
| 193 | + public static readonly AppleSdkVersion V9_1 = new AppleSdkVersion (9, 1); |
| 194 | + public static readonly AppleSdkVersion V9_2 = new AppleSdkVersion (9, 2); |
| 195 | + public static readonly AppleSdkVersion V9_3 = new AppleSdkVersion (9, 3); |
| 196 | + public static readonly AppleSdkVersion V10_0 = new AppleSdkVersion (10, 0); |
| 197 | + public static readonly AppleSdkVersion V10_1 = new AppleSdkVersion (10, 1); |
| 198 | + public static readonly AppleSdkVersion V10_2 = new AppleSdkVersion (10, 2); |
| 199 | + public static readonly AppleSdkVersion V10_3 = new AppleSdkVersion (10, 3); |
| 200 | + public static readonly AppleSdkVersion V10_4 = new AppleSdkVersion (10, 4); |
| 201 | + public static readonly AppleSdkVersion V10_5 = new AppleSdkVersion (10, 5); |
| 202 | + public static readonly AppleSdkVersion V10_6 = new AppleSdkVersion (10, 6); |
| 203 | + public static readonly AppleSdkVersion V10_7 = new AppleSdkVersion (10, 7); |
| 204 | + public static readonly AppleSdkVersion V10_8 = new AppleSdkVersion (10, 8); |
| 205 | + public static readonly AppleSdkVersion V10_9 = new AppleSdkVersion (10, 9); |
| 206 | + public static readonly AppleSdkVersion V10_10 = new AppleSdkVersion (10, 10); |
| 207 | + public static readonly AppleSdkVersion V10_11 = new AppleSdkVersion (10, 11); |
| 208 | + public static readonly AppleSdkVersion V10_12 = new AppleSdkVersion (10, 12); |
| 209 | + public static readonly AppleSdkVersion V10_13 = new AppleSdkVersion (10, 13); |
| 210 | + public static readonly AppleSdkVersion V10_14 = new AppleSdkVersion (10, 14); |
| 211 | + public static readonly AppleSdkVersion V10_15 = new AppleSdkVersion (10, 15); |
| 212 | + public static readonly AppleSdkVersion V11_0 = new AppleSdkVersion (11, 0); |
| 213 | + } |
| 214 | +} |
0 commit comments