Compact lambda expressions in some (not all) places

This commit is contained in:
ScottNZ
2014-06-14 01:57:46 +12:00
parent 375fc1c5f1
commit 6b85660d7d
8 changed files with 16 additions and 34 deletions

View File

@@ -65,19 +65,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic
mirror != null ? new Uri(mirror).Host : "unknown host");
};
Action<string> onExtractProgress = s =>
{
Game.RunAfterTick(() => statusLabel.GetText = () => s);
};
Action<string> onExtractProgress = s => Game.RunAfterTick(() => statusLabel.GetText = () => s);
Action<string> onError = s =>
Action<string> onError = s => Game.RunAfterTick(() =>
{
Game.RunAfterTick(() =>
{
statusLabel.GetText = () => "Error: " + s;
retryButton.IsVisible = () => true;
});
};
statusLabel.GetText = () => "Error: " + s;
retryButton.IsVisible = () => true;
});
Action<AsyncCompletedEventArgs, bool> onDownloadComplete = (i, cancelled) =>
{

View File

@@ -66,10 +66,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
});
};
Action<string> onRetry = password =>
{
ConnectionLogic.Connect(om.Host, om.Port, password, onConnect, onExit);
};
Action<string> onRetry = password => ConnectionLogic.Connect(om.Host, om.Port, password, onConnect, onExit);
Ui.OpenWindow("CONNECTIONFAILED_PANEL", new WidgetArgs()
{

View File

@@ -58,8 +58,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
replays = Directory
.GetFiles(dir, "*.rep")
.Select((filename) => ReplayMetadata.Read(filename))
.Where((r) => r != null)
.Select(ReplayMetadata.Read)
.Where(r => r != null)
.OrderByDescending(r => r.GameInfo.StartTimeUtc)
.ToList();
}
@@ -365,14 +365,11 @@ namespace OpenRA.Mods.RA.Widgets.Logic
"Rename Replay",
"Enter a new file name:",
initialName,
onAccept: (newName) =>
{
RenameReplay(r, newName);
},
onAccept: newName => RenameReplay(r, newName),
onCancel: null,
acceptText: "Rename",
cancelText: null,
inputValidator: (newName) =>
inputValidator: newName =>
{
if (newName == initialName)
return false;
@@ -439,7 +436,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
"Delete {0} replays?".F(list.Count),
() =>
{
list.ForEach((r) => DeleteReplay(r));
list.ForEach(DeleteReplay);
if (selectedReplay == null)
SelectFirstVisibleReplay();
},