Remove Exts.WithDefault
This commit is contained in:
committed by
Matthias Mailänder
parent
169c60883b
commit
388222c5c7
@@ -32,12 +32,6 @@ namespace OpenRA
|
||||
return string.Format(CultureInfo.CurrentCulture, format, args);
|
||||
}
|
||||
|
||||
public static T WithDefault<T>(T def, Func<T> f)
|
||||
{
|
||||
try { return f(); }
|
||||
catch { return def; }
|
||||
}
|
||||
|
||||
public static Lazy<T> Lazy<T>(Func<T> p) { return new Lazy<T>(p); }
|
||||
|
||||
public static IEnumerable<string> GetNamespaces(this Assembly a)
|
||||
|
||||
@@ -46,7 +46,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
joinButton.OnClick = () =>
|
||||
{
|
||||
var port = Exts.WithDefault(1234, () => int.Parse(portField.Text, NumberFormatInfo.CurrentInfo));
|
||||
if (!int.TryParse(portField.Text, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, out var port))
|
||||
port = 1234;
|
||||
|
||||
Game.Settings.Player.LastServer = $"{ipField.Text}:{port}";
|
||||
Game.Settings.Save();
|
||||
|
||||
Reference in New Issue
Block a user