Start to extract some duplicate code out into extension methods - saves repeating the same block three times

This commit is contained in:
amaitland
2015-05-21 10:57:18 +10:00
parent 7541ca2d3b
commit e43befe9fa
5 changed files with 31 additions and 34 deletions
+1 -11
View File
@@ -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;
+1 -11
View File
@@ -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);
+2 -12
View File
@@ -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)
{
+1
View File
@@ -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" />
+26
View File
@@ -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;
}
}
}