Skip to content

Commit 43bdfaf

Browse files
committed
remove indendation, swap condition
1 parent d2514a3 commit 43bdfaf

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Input/Command/MouseActionConverter.cs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -114,23 +114,21 @@ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo cul
114114
{
115115
ArgumentNullException.ThrowIfNull(destinationType);
116116

117-
if (destinationType == typeof(string) && value is not null)
118-
{
119-
return (MouseAction)value switch
120-
{
121-
MouseAction.None => string.Empty,
122-
MouseAction.LeftClick => "LeftClick",
123-
MouseAction.RightClick => "RightClick",
124-
MouseAction.MiddleClick => "MiddleClick",
125-
MouseAction.WheelClick => "WheelClick",
126-
MouseAction.LeftDoubleClick => "LeftDoubleClick",
127-
MouseAction.RightDoubleClick => "RightDoubleClick",
128-
MouseAction.MiddleDoubleClick => "MiddleDoubleClick",
129-
_ => throw new InvalidEnumArgumentException(nameof(value), (int)value, typeof(MouseAction))
130-
};
131-
}
117+
if (value is null || destinationType != typeof(string))
118+
throw GetConvertToException(value, destinationType);
132119

133-
throw GetConvertToException(value,destinationType);
120+
return (MouseAction)value switch
121+
{
122+
MouseAction.None => string.Empty,
123+
MouseAction.LeftClick => "LeftClick",
124+
MouseAction.RightClick => "RightClick",
125+
MouseAction.MiddleClick => "MiddleClick",
126+
MouseAction.WheelClick => "WheelClick",
127+
MouseAction.LeftDoubleClick => "LeftDoubleClick",
128+
MouseAction.RightDoubleClick => "RightDoubleClick",
129+
MouseAction.MiddleDoubleClick => "MiddleDoubleClick",
130+
_ => throw new InvalidEnumArgumentException(nameof(value), (int)value, typeof(MouseAction))
131+
};
134132
}
135133

136134
// Helper like Enum.IsDefined, for MouseAction.

0 commit comments

Comments
 (0)