User pattern matching

This commit is contained in:
Dean Herbert 2018-04-25 16:32:06 +09:00
parent 4f53185d43
commit 6e6586909b
1 changed files with 2 additions and 4 deletions

View File

@ -46,8 +46,7 @@ public SampleChannel GetSample(string sampleName)
public TValue? GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue?> query) where TConfiguration : SkinConfiguration where TValue : struct
{
TValue? val = null;
var conf = (source as Skin)?.Configuration as TConfiguration;
if (conf != null)
if ((source as Skin)?.Configuration is TConfiguration conf)
val = query?.Invoke(conf);
return val ?? fallbackSource?.GetValue(query);
@ -56,8 +55,7 @@ public SampleChannel GetSample(string sampleName)
public TValue GetValue<TConfiguration, TValue>(Func<TConfiguration, TValue> query) where TConfiguration : SkinConfiguration where TValue : class
{
TValue val = null;
var conf = (source as Skin)?.Configuration as TConfiguration;
if (conf != null)
if ((source as Skin)?.Configuration is TConfiguration conf)
val = query?.Invoke(conf);
return val ?? fallbackSource?.GetValue(query);