Skip to content

Commit

Permalink
Revert overeager pattern matching
Browse files Browse the repository at this point in the history
  • Loading branch information
IvenBach committed Nov 21, 2017
1 parent e3f5587 commit 24a2bb6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 27 deletions.
Expand Up @@ -9,13 +9,13 @@ public class DeclarationTypeToStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is DeclarationType type))
if (value is DeclarationType type)
{
return null;
var text = RubberduckUI.ResourceManager.GetString("DeclarationType_" + type, CultureInfo.CurrentUICulture) ?? string.Empty;
return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(text);
}

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

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
Expand Down
42 changes: 20 additions & 22 deletions RetailCoder.VBE/UI/Controls/MenuItemGroup.cs
Expand Up @@ -31,33 +31,31 @@ private static void OnGroupNameChanged(DependencyObject d, DependencyPropertyCha
{
//Add an entry to the group name collection

if (!(d is MenuItem menuItem))
if (d is MenuItem menuItem)
{
return;
}

var newGroupName = e.NewValue.ToString();
var oldGroupName = e.OldValue.ToString();
if (string.IsNullOrEmpty(newGroupName))
{
//Removing the toggle button from grouping
RemoveCheckboxFromGrouping(menuItem);
}
else
{
//Switching to a new group
if (newGroupName == oldGroupName)
var newGroupName = e.NewValue.ToString();
var oldGroupName = e.OldValue.ToString();
if (string.IsNullOrEmpty(newGroupName))
{
return;
//Removing the toggle button from grouping
RemoveCheckboxFromGrouping(menuItem);
}

if (!string.IsNullOrEmpty(oldGroupName))
else
{
//Remove the old group mapping
RemoveCheckboxFromGrouping(menuItem);
//Switching to a new group
if (newGroupName == oldGroupName)
{
return;
}

if (!string.IsNullOrEmpty(oldGroupName))
{
//Remove the old group mapping
RemoveCheckboxFromGrouping(menuItem);
}
ElementToGroupNames.Add(menuItem, e.NewValue.ToString());
menuItem.Checked += MenuItemChecked;
}
ElementToGroupNames.Add(menuItem, e.NewValue.ToString());
menuItem.Checked += MenuItemChecked;
}
}

Expand Down
Expand Up @@ -9,7 +9,8 @@ public class InspectionImageSourceConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is IInspection inspection))
var inspection = value as IInspection;
if (inspection == null )
{
return null;
}
Expand Down

0 comments on commit 24a2bb6

Please sign in to comment.