mirror of
https://github.com/ppy/osu.git
synced 2025-03-06 03:42:55 +08:00
User pattern matching
This commit is contained in:
parent
4f53185d43
commit
6e6586909b
@ -46,8 +46,7 @@ namespace osu.Game.Skinning
|
|||||||
public TValue? GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue?> query) where TConfiguration : SkinConfiguration where TValue : struct
|
public TValue? GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue?> query) where TConfiguration : SkinConfiguration where TValue : struct
|
||||||
{
|
{
|
||||||
TValue? val = null;
|
TValue? val = null;
|
||||||
var conf = (source as Skin)?.Configuration as TConfiguration;
|
if ((source as Skin)?.Configuration is TConfiguration conf)
|
||||||
if (conf != null)
|
|
||||||
val = query?.Invoke(conf);
|
val = query?.Invoke(conf);
|
||||||
|
|
||||||
return val ?? fallbackSource?.GetValue(query);
|
return val ?? fallbackSource?.GetValue(query);
|
||||||
@ -56,8 +55,7 @@ namespace osu.Game.Skinning
|
|||||||
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration where TValue : class
|
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration where TValue : class
|
||||||
{
|
{
|
||||||
TValue val = null;
|
TValue val = null;
|
||||||
var conf = (source as Skin)?.Configuration as TConfiguration;
|
if ((source as Skin)?.Configuration is TConfiguration conf)
|
||||||
if (conf != null)
|
|
||||||
val = query?.Invoke(conf);
|
val = query?.Invoke(conf);
|
||||||
|
|
||||||
return val ?? fallbackSource?.GetValue(query);
|
return val ?? fallbackSource?.GetValue(query);
|
||||||
|
Loading…
Reference in New Issue
Block a user