mirror of
https://github.com/ppy/osu
synced 2024-12-14 02:46:27 +00:00
Better expression to avoid invalid values
This commit is contained in:
parent
d787c740fa
commit
d86e81f07c
@ -82,7 +82,21 @@ namespace osu.Game.Beatmaps
|
||||
public string StoredBookmarks
|
||||
{
|
||||
get { return string.Join(",", Bookmarks); }
|
||||
set { Bookmarks = value?.Split(',').Select(v => int.Parse(v.Trim())).ToArray() ?? new int[0]; }
|
||||
set
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
Bookmarks = new int[0];
|
||||
return;
|
||||
}
|
||||
|
||||
Bookmarks = value.Split(',').Select(v =>
|
||||
{
|
||||
int val;
|
||||
bool result = int.TryParse(v, out val);
|
||||
return new { result, val };
|
||||
}).Where(p => p.result).Select(p => p.val).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
[Ignore]
|
||||
|
Loading…
Reference in New Issue
Block a user