Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions Xamarin.MacDev/IAppleSdkVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,36 @@ public static IAppleSdkVersion GetDefault (this IAppleSdkVersion @this, IAppleSd
return v.Count > 0 ? v [v.Count - 1] : @this.GetUseDefault ();
}

public static bool TryParse<T> (string s, out T result) where T : IAppleSdkVersion, new()
public static bool TryParse (string s, out int[] result)
{
result = new T ();
if (s == null)
if (s == null) {
result = null;
return false;
}

var vstr = s.Split ('.');
var vint = new int [vstr.Length];
result = new int [vstr.Length];

for (int j = 0; j < vstr.Length; j++) {
int component;
if (!int.TryParse (vstr [j], out component))
return false;

vint [j] = component;
result [j] = component;
}

return true;
}

public static bool TryParse<T> (string s, out T result) where T : IAppleSdkVersion, new()
{
result = new T ();
if (s == null)
return false;

if (!TryParse (s, out var vint))
return false;

result.SetVersion (vint);
return true;
}
Expand Down