Skip to content

Commit 24a2bb6

Browse files
committed
Revert overeager pattern matching
1 parent e3f5587 commit 24a2bb6

File tree

3 files changed

+26
-27
lines changed

3 files changed

+26
-27
lines changed

RetailCoder.VBE/UI/Controls/DeclarationTypeToStringConverter.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ public class DeclarationTypeToStringConverter : IValueConverter
99
{
1010
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
1111
{
12-
if (!(value is DeclarationType type))
12+
if (value is DeclarationType type)
1313
{
14-
return null;
14+
var text = RubberduckUI.ResourceManager.GetString("DeclarationType_" + type, CultureInfo.CurrentUICulture) ?? string.Empty;
15+
return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(text);
1516
}
1617

17-
var text = RubberduckUI.ResourceManager.GetString("DeclarationType_" + type, CultureInfo.CurrentUICulture) ?? string.Empty;
18-
return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(text);
18+
return null;
1919
}
2020

2121
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)

RetailCoder.VBE/UI/Controls/MenuItemGroup.cs

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,31 @@ private static void OnGroupNameChanged(DependencyObject d, DependencyPropertyCha
3131
{
3232
//Add an entry to the group name collection
3333

34-
if (!(d is MenuItem menuItem))
34+
if (d is MenuItem menuItem)
3535
{
36-
return;
37-
}
38-
39-
var newGroupName = e.NewValue.ToString();
40-
var oldGroupName = e.OldValue.ToString();
41-
if (string.IsNullOrEmpty(newGroupName))
42-
{
43-
//Removing the toggle button from grouping
44-
RemoveCheckboxFromGrouping(menuItem);
45-
}
46-
else
47-
{
48-
//Switching to a new group
49-
if (newGroupName == oldGroupName)
36+
var newGroupName = e.NewValue.ToString();
37+
var oldGroupName = e.OldValue.ToString();
38+
if (string.IsNullOrEmpty(newGroupName))
5039
{
51-
return;
40+
//Removing the toggle button from grouping
41+
RemoveCheckboxFromGrouping(menuItem);
5242
}
53-
54-
if (!string.IsNullOrEmpty(oldGroupName))
43+
else
5544
{
56-
//Remove the old group mapping
57-
RemoveCheckboxFromGrouping(menuItem);
45+
//Switching to a new group
46+
if (newGroupName == oldGroupName)
47+
{
48+
return;
49+
}
50+
51+
if (!string.IsNullOrEmpty(oldGroupName))
52+
{
53+
//Remove the old group mapping
54+
RemoveCheckboxFromGrouping(menuItem);
55+
}
56+
ElementToGroupNames.Add(menuItem, e.NewValue.ToString());
57+
menuItem.Checked += MenuItemChecked;
5858
}
59-
ElementToGroupNames.Add(menuItem, e.NewValue.ToString());
60-
menuItem.Checked += MenuItemChecked;
6159
}
6260
}
6361

RetailCoder.VBE/UI/Inspections/InspectionImageSourceConverter.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ public class InspectionImageSourceConverter : IValueConverter
99
{
1010
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
1111
{
12-
if (!(value is IInspection inspection))
12+
var inspection = value as IInspection;
13+
if (inspection == null )
1314
{
1415
return null;
1516
}

0 commit comments

Comments
 (0)