Browse Source

Changed Toolbar.GetSetting<T> method. Null is returned instead of throwing exception when the value has wrong type

ArtemK123 4 years ago
parent
commit
875fc61add
1 changed files with 2 additions and 5 deletions
  1. 2 5
      PixiEditor/Models/Tools/ToolSettings/Toolbars/Toolbar.cs

+ 2 - 5
PixiEditor/Models/Tools/ToolSettings/Toolbars/Toolbar.cs

@@ -30,13 +30,10 @@ namespace PixiEditor.Models.Tools.ToolSettings.Toolbars
         {
         {
             Setting setting =  Settings.FirstOrDefault(currentSetting => string.Equals(currentSetting.Name, name, StringComparison.CurrentCultureIgnoreCase));
             Setting setting =  Settings.FirstOrDefault(currentSetting => string.Equals(currentSetting.Name, name, StringComparison.CurrentCultureIgnoreCase));
 
 
-            if (setting == null)
+            if (setting == null || !(setting is Setting<T> convertedSetting))
                 return null;
                 return null;
 
 
-            if (setting is Setting<T> convertedSetting)
-                return convertedSetting;
-
-            throw new Exception("Setting has value with unexpected type");
+            return convertedSetting;
         }
         }
 
 
         /// <summary>
         /// <summary>