Use pattern matching wherever possible

This commit is contained in:
Dean Herbert
2019-02-28 14:35:00 +09:00
parent 94a389319d
commit e2c6a8bc07
13 changed files with 17 additions and 29 deletions

View File

@ -37,11 +37,9 @@ namespace osu.Game.Graphics.UserInterface
private void updateAccentColour()
{
var header = Header as IHasAccentColour;
if (header != null) header.AccentColour = accentColour;
if (Header is IHasAccentColour header) header.AccentColour = accentColour;
var menu = Menu as IHasAccentColour;
if (menu != null) menu.AccentColour = accentColour;
if (Menu is IHasAccentColour menu) menu.AccentColour = accentColour;
}
protected override DropdownHeader CreateHeader() => new OsuDropdownHeader();
@ -149,8 +147,7 @@ namespace osu.Game.Graphics.UserInterface
{
base.UpdateForegroundColour();
var content = Foreground.Children.FirstOrDefault() as Content;
if (content != null) content.Chevron.Alpha = IsHovered ? 1 : 0;
if (Foreground.Children.FirstOrDefault() is Content content) content.Chevron.Alpha = IsHovered ? 1 : 0;
}
protected override Drawable CreateContent() => new Content();