style: remove repeated code, group in tasks
This commit is contained in:
+13
-18
@@ -10,33 +10,28 @@ if (!hasInitialized)
|
||||
return 1;
|
||||
}
|
||||
|
||||
log.Info("Getting character data and icons");
|
||||
var dumpTasks = new (string Name, Action Execute)[]
|
||||
{
|
||||
("character", () => { dumper.DumpCharacters(); dumper.DumpCharacterIcons(); }),
|
||||
("item", () => { dumper.DumpItems(); dumper.DumpItemIcons(); }),
|
||||
("offering", () => { dumper.DumpOfferings(); dumper.DumpOfferingIcons(); })
|
||||
};
|
||||
|
||||
foreach (var task in dumpTasks)
|
||||
{
|
||||
log.Info($"Getting {task.Name} data and icons");
|
||||
|
||||
try
|
||||
{
|
||||
dumper.DumpCharacters();
|
||||
dumper.DumpCharacterIcons();
|
||||
task.Execute();
|
||||
}
|
||||
catch (Exception er)
|
||||
{
|
||||
log.Error("Error while dumping characters");
|
||||
log.Error($"Error while dumping {task.Name}s");
|
||||
log.Error("Exception: {0}", er.ToString());
|
||||
Console.ReadKey();
|
||||
return 1;
|
||||
}
|
||||
|
||||
log.Info("Getting item data and icons");
|
||||
try
|
||||
{
|
||||
dumper.DumpItems();
|
||||
dumper.DumpItemIcons();
|
||||
}
|
||||
catch (Exception er)
|
||||
{
|
||||
log.Error("Error while dumping items");
|
||||
log.Error("Exception: {0}", er.ToString());
|
||||
Console.ReadKey();
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
log.Info("Dump finished");
|
||||
|
||||
Reference in New Issue
Block a user