Skip to content

Commit

Permalink
Removed C# 8.0 feature usage
Browse files Browse the repository at this point in the history
  • Loading branch information
kekekeks committed Feb 7, 2020
1 parent 1eb3d87 commit a3ab157
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/Avalonia.Controls/Platform/DefaultMenuInteractionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ namespace Avalonia.Controls.Platform
public class DefaultMenuInteractionHandler : IMenuInteractionHandler
{
private readonly bool _isContextMenu;
private IDisposable? _inputManagerSubscription;
private IRenderRoot? _root;
private IDisposable _inputManagerSubscription;
private IRenderRoot _root;

public DefaultMenuInteractionHandler(bool isContextMenu)
: this(isContextMenu, Input.InputManager.Instance, DefaultDelayRun)
Expand All @@ -24,7 +24,7 @@ public DefaultMenuInteractionHandler(bool isContextMenu)

public DefaultMenuInteractionHandler(
bool isContextMenu,
IInputManager? inputManager,
IInputManager inputManager,
Action<Action, TimeSpan> delayRun)
{
delayRun = delayRun ?? throw new ArgumentNullException(nameof(delayRun));
Expand Down Expand Up @@ -94,17 +94,17 @@ public virtual void Detach(IMenu menu)
root.Deactivated -= WindowDeactivated;
}

_inputManagerSubscription!.Dispose();
_inputManagerSubscription.Dispose();

Menu = null;
_root = null;
}

protected Action<Action, TimeSpan> DelayRun { get; }

protected IInputManager? InputManager { get; }
protected IInputManager InputManager { get; }

protected IMenu? Menu { get; private set; }
protected IMenu Menu { get; private set; }

protected static TimeSpan MenuShowDelay { get; } = TimeSpan.FromMilliseconds(400);

Expand Down Expand Up @@ -133,7 +133,7 @@ protected internal virtual void KeyDown(object sender, KeyEventArgs e)
KeyDown(GetMenuItem(e.Source as IControl), e);
}

protected internal virtual void KeyDown(IMenuItem? item, KeyEventArgs e)
protected internal virtual void KeyDown(IMenuItem item, KeyEventArgs e)
{
switch (e.Key)
{
Expand Down Expand Up @@ -202,7 +202,7 @@ protected internal virtual void KeyDown(IMenuItem? item, KeyEventArgs e)
}
else
{
Menu!.Close();
Menu.Close();
}

e.Handled = true;
Expand All @@ -215,7 +215,7 @@ protected internal virtual void KeyDown(IMenuItem? item, KeyEventArgs e)
{
if (item == null && _isContextMenu)
{
if (Menu!.MoveSelection(direction.Value, true) == true)
if (Menu.MoveSelection(direction.Value, true) == true)
{
e.Handled = true;
}
Expand Down Expand Up @@ -410,7 +410,7 @@ protected void Click(IMenuItem item)

protected void CloseMenu(IMenuItem item)
{
var current = (IMenuElement?)item;
var current = (IMenuElement)item;

while (current != null && !(current is IMenu))
{
Expand Down Expand Up @@ -458,7 +458,7 @@ void Execute()

protected void SelectItemAndAncestors(IMenuItem item)
{
var current = (IMenuItem?)item;
var current = item;

while (current?.Parent != null)
{
Expand All @@ -467,7 +467,7 @@ protected void SelectItemAndAncestors(IMenuItem item)
}
}

protected static IMenuItem? GetMenuItem(IControl? item)
protected static IMenuItem GetMenuItem(IControl item)
{
while (true)
{
Expand Down

0 comments on commit a3ab157

Please sign in to comment.