mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 10:23:03 +08: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
|
public string StoredBookmarks
|
||||||
{
|
{
|
||||||
get { return string.Join(",", Bookmarks); }
|
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]
|
[Ignore]
|
||||||
|
Loading…
Reference in New Issue
Block a user