mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 10:22:55 +00:00
Start to extract some duplicate code out into extension methods - saves repeating the same block three times
This commit is contained in:
@@ -109,17 +109,7 @@ namespace CefSharp.OffScreen
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
// Don't reference handlers any longer:
|
||||
ResourceHandlerFactory = null;
|
||||
JsDialogHandler = null;
|
||||
DialogHandler = null;
|
||||
DownloadHandler = null;
|
||||
KeyboardHandler = null;
|
||||
LifeSpanHandler = null;
|
||||
MenuHandler = null;
|
||||
FocusHandler = null;
|
||||
RequestHandler = null;
|
||||
DragHandler = null;
|
||||
GeolocationHandler = null;
|
||||
this.SetHandlersToNull();
|
||||
|
||||
// Don't reference event listeners any longer:
|
||||
LoadError = null;
|
||||
|
||||
@@ -102,17 +102,7 @@ namespace CefSharp.WinForms
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
// Don't utilize any of the handlers anymore:
|
||||
DialogHandler = null;
|
||||
JsDialogHandler = null;
|
||||
KeyboardHandler = null;
|
||||
RequestHandler = null;
|
||||
DownloadHandler = null;
|
||||
LifeSpanHandler = null;
|
||||
MenuHandler = null;
|
||||
DragHandler = null;
|
||||
GeolocationHandler = null;
|
||||
FocusHandler = null;
|
||||
ResourceHandlerFactory = null;
|
||||
this.SetHandlersToNull();
|
||||
|
||||
Cef.RemoveDisposable(this);
|
||||
|
||||
|
||||
@@ -174,20 +174,10 @@ namespace CefSharp.Wpf
|
||||
FrameLoadEnd = null;
|
||||
LoadError = null;
|
||||
LoadingStateChanged = null;
|
||||
Rendering = null;
|
||||
|
||||
// No longer reference handlers:
|
||||
ResourceHandlerFactory = null;
|
||||
DialogHandler = null;
|
||||
JsDialogHandler = null;
|
||||
KeyboardHandler = null;
|
||||
RequestHandler = null;
|
||||
DownloadHandler = null;
|
||||
LifeSpanHandler = null;
|
||||
MenuHandler = null;
|
||||
FocusHandler = null;
|
||||
DragHandler = null;
|
||||
GeolocationHandler = null;
|
||||
Rendering = null;
|
||||
this.SetHandlersToNull();
|
||||
|
||||
if (isdisposing)
|
||||
{
|
||||
|
||||
@@ -165,6 +165,7 @@
|
||||
<Compile Include="ILifeSpanHandler.cs" />
|
||||
<Compile Include="IMenuHandler.cs" />
|
||||
<Compile Include="Internals\IRenderWebBrowser.cs" />
|
||||
<Compile Include="WebBrowserExtensions.cs" />
|
||||
<Compile Include="WebPluginInfo.cs" />
|
||||
<Compile Include="IRequest.cs" />
|
||||
<Compile Include="IRequestHandler.cs" />
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright © 2010-2015 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 CefSharp.Internals;
|
||||
|
||||
namespace CefSharp
|
||||
{
|
||||
internal static class WebBrowserExtensions
|
||||
{
|
||||
internal static void SetHandlersToNull(this IWebBrowserInternal browser)
|
||||
{
|
||||
browser.ResourceHandlerFactory = null;
|
||||
browser.JsDialogHandler = null;
|
||||
browser.DialogHandler = null;
|
||||
browser.DownloadHandler = null;
|
||||
browser.KeyboardHandler = null;
|
||||
browser.LifeSpanHandler = null;
|
||||
browser.MenuHandler = null;
|
||||
browser.FocusHandler = null;
|
||||
browser.RequestHandler = null;
|
||||
browser.DragHandler = null;
|
||||
browser.GeolocationHandler = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user