From be4f4ed1c2d5d34b6bf52b095cf9f6036fa52648 Mon Sep 17 00:00:00 2001 From: Rustam Sayfutdinov Date: Wed, 24 Jun 2020 20:49:25 +0500 Subject: [PATCH] Fix using pattern matching --- .../Animation/Animators/SolidColorBrushAnimator.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Avalonia.Visuals/Animation/Animators/SolidColorBrushAnimator.cs b/src/Avalonia.Visuals/Animation/Animators/SolidColorBrushAnimator.cs index 8f0b710f63..d60542a6b4 100644 --- a/src/Avalonia.Visuals/Animation/Animators/SolidColorBrushAnimator.cs +++ b/src/Avalonia.Visuals/Animation/Animators/SolidColorBrushAnimator.cs @@ -51,17 +51,14 @@ namespace Avalonia.Animation.Animators if (_colorAnimator == null) InitializeColorAnimator(); - SolidColorBrush finalTarget; - // If it's ISCB, change it back to SCB. - if (targetVal.GetType() == typeof(ImmutableSolidColorBrush)) + if (targetVal is ImmutableSolidColorBrush immutableSolidColorBrush) { - var col = (ImmutableSolidColorBrush)targetVal; - targetVal = new SolidColorBrush(col.Color); + targetVal = new SolidColorBrush(immutableSolidColorBrush.Color); control.SetValue(Property, targetVal); } - finalTarget = targetVal as SolidColorBrush; + var finalTarget = targetVal as SolidColorBrush; return _colorAnimator.Apply(animation, finalTarget, clock ?? control.Clock, match, onComplete); }