From 83f4414420dfc092f4f87e262998097b7afe6c84 Mon Sep 17 00:00:00 2001
From: amaitland <307872+amaitland@users.noreply.github.com>
Date: Thu, 5 Dec 2024 18:53:52 +1000
Subject: [PATCH] HwndHost - Delete delegate command
---
CefSharp.Wpf/Handler/ContextMenuHandler.cs | 1 +
CefSharp.Wpf/HwndHost/ChromiumWebBrowser.cs | 1 +
.../HwndHost/Internals/DelegateCommand.cs | 68 -------------------
.../{ => Internals}/DelegateCommand.cs | 9 +--
4 files changed, 5 insertions(+), 74 deletions(-)
delete mode 100644 CefSharp.Wpf/HwndHost/Internals/DelegateCommand.cs
rename CefSharp.Wpf/{ => Internals}/DelegateCommand.cs (91%)
diff --git a/CefSharp.Wpf/Handler/ContextMenuHandler.cs b/CefSharp.Wpf/Handler/ContextMenuHandler.cs
index 57da637aa7..2bf9c4728d 100644
--- a/CefSharp.Wpf/Handler/ContextMenuHandler.cs
+++ b/CefSharp.Wpf/Handler/ContextMenuHandler.cs
@@ -6,6 +6,7 @@
using System.Windows.Controls.Primitives;
using System.Windows.Controls;
using System.Windows;
+using CefSharp.Wpf.Internals;
namespace CefSharp.Wpf.Handler
{
diff --git a/CefSharp.Wpf/HwndHost/ChromiumWebBrowser.cs b/CefSharp.Wpf/HwndHost/ChromiumWebBrowser.cs
index 78d34b167e..36143c170c 100644
--- a/CefSharp.Wpf/HwndHost/ChromiumWebBrowser.cs
+++ b/CefSharp.Wpf/HwndHost/ChromiumWebBrowser.cs
@@ -15,6 +15,7 @@
using CefSharp.Internals;
using CefSharp.Structs;
using CefSharp.Wpf.HwndHost.Internals;
+using CefSharp.Wpf.Internals;
namespace CefSharp.Wpf.HwndHost
{
diff --git a/CefSharp.Wpf/HwndHost/Internals/DelegateCommand.cs b/CefSharp.Wpf/HwndHost/Internals/DelegateCommand.cs
deleted file mode 100644
index ddc16f8678..0000000000
--- a/CefSharp.Wpf/HwndHost/Internals/DelegateCommand.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright © 2019 The CefSharp Authors. All rights reserved.
-//
-// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
-
-using System;
-using System.Windows.Input;
-
-namespace CefSharp.Wpf.HwndHost.Internals
-{
- ///
- /// DelegateCommand
- ///
- ///
- internal class DelegateCommand : ICommand
- {
- ///
- /// The command handler
- ///
- private readonly Action commandHandler;
- ///
- /// The can execute handler
- ///
- private readonly Func canExecuteHandler;
-
- ///
- /// Occurs when changes occur that affect whether or not the command should execute.
- ///
- public event EventHandler CanExecuteChanged;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The command handler.
- /// The can execute handler.
- public DelegateCommand(Action commandHandler, Func canExecuteHandler = null)
- {
- this.commandHandler = commandHandler;
- this.canExecuteHandler = canExecuteHandler;
- }
-
- ///
- /// Defines the method to be called when the command is invoked.
- ///
- /// Data used by the command. If the command does not require data to be passed, this object can be set to null.
- public void Execute(object parameter)
- {
- commandHandler();
- }
-
- ///
- /// Defines the method that determines whether the command can execute in its current state.
- ///
- /// Data used by the command. If the command does not require data to be passed, this object can be set to null.
- /// true if this command can be executed; otherwise, false.
- public bool CanExecute(object parameter)
- {
- return canExecuteHandler == null || canExecuteHandler();
- }
-
- ///
- /// Raises the can execute changed.
- ///
- public void RaiseCanExecuteChanged()
- {
- CanExecuteChanged?.Invoke(this, EventArgs.Empty);
- }
- }
-}
diff --git a/CefSharp.Wpf/DelegateCommand.cs b/CefSharp.Wpf/Internals/DelegateCommand.cs
similarity index 91%
rename from CefSharp.Wpf/DelegateCommand.cs
rename to CefSharp.Wpf/Internals/DelegateCommand.cs
index ba4002a459..abf505f57b 100644
--- a/CefSharp.Wpf/DelegateCommand.cs
+++ b/CefSharp.Wpf/Internals/DelegateCommand.cs
@@ -5,12 +5,12 @@
using System;
using System.Windows.Input;
-namespace CefSharp.Wpf
+namespace CefSharp.Wpf.Internals
{
///
/// DelegateCommand
///
- ///
+ ///
internal class DelegateCommand : ICommand
{
///
@@ -64,10 +64,7 @@ public bool CanExecute(object parameter)
///
public void RaiseCanExecuteChanged()
{
- if (CanExecuteChanged != null)
- {
- CanExecuteChanged(this, EventArgs.Empty);
- }
+ CanExecuteChanged?.Invoke(this, EventArgs.Empty);
}
}
}