[mapguide-commits] r8751 - in trunk/Tools/Maestro: Maestro.AddIn.Scripting/Lang/Python Maestro.AddIn.Scripting/UI Maestro.Base/Services Maestro.Base/UI Maestro.Editors/Common Maestro.Editors/Common/Expression Maestro.Editors/FeatureSource Maestro.Editors/Fusion Maestro.Editors/SymbolDefinition Maestro.Editors/WebLayout Maestro.Login Maestro.MapViewer Maestro.Shared.UI MgCooker OSGeo.MapGuide.MaestroAPI OSGeo.MapGuide.MaestroAPI/Feature OSGeo.MapGuide.MaestroAPI/Schema OSGeo.MapGuide.MaestroAPI/Tile OSGeo.MapGuide.MaestroAPI.Http OSGeo.MapGuide.MaestroAPI.Local OSGeo.MapGuide.MaestroAPI.Native OSGeo.MapGuide.ObjectModels OSGeo.MapGuide.ObjectModels/WebLayout OSGeo.MapGuide.ObjectModels/WebLayout/v1_0_0 OSGeo.MapGuide.ObjectModels/WebLayout/v1_1_0 OSGeo.MapGuide.ObjectModels/WebLayout/v2_4_0 OSGeo.MapGuide.ObjectModels/WebLayout/v2_6_0 Properties
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Tue Aug 18 10:04:11 PDT 2015
Author: jng
Date: 2015-08-18 10:04:11 -0700 (Tue, 18 Aug 2015)
New Revision: 8751
Modified:
trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsole.cs
trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.cs
trunk/Tools/Maestro/Maestro.Base/Services/OpenResourceManager.cs
trunk/Tools/Maestro/Maestro.Base/UI/ResourceIconCache.cs
trunk/Tools/Maestro/Maestro.Base/UI/ResourceIdNavigator.cs
trunk/Tools/Maestro/Maestro.Base/UI/ResourcePropertiesDialog.cs
trunk/Tools/Maestro/Maestro.Editors/Common/ColorComboBox.cs
trunk/Tools/Maestro/Maestro.Editors/Common/Expression/FdoExpressionCompletionDataProvider.cs
trunk/Tools/Maestro/Maestro.Editors/Common/ExpressionEditor.cs
trunk/Tools/Maestro/Maestro.Editors/Common/ITextEditor.cs
trunk/Tools/Maestro/Maestro.Editors/Common/TextEditor.cs
trunk/Tools/Maestro/Maestro.Editors/FeatureSource/ExtensionsCtrl.cs
trunk/Tools/Maestro/Maestro.Editors/Fusion/MapSettingsCtrl.cs
trunk/Tools/Maestro/Maestro.Editors/Fusion/WidgetManagementDialog.cs
trunk/Tools/Maestro/Maestro.Editors/Fusion/WidgetSettingsCtrl.cs
trunk/Tools/Maestro/Maestro.Editors/SymbolDefinition/SymbolEditorService.cs
trunk/Tools/Maestro/Maestro.Editors/WebLayout/MenuEditorCtrl.cs
trunk/Tools/Maestro/Maestro.Editors/WebLayout/WebLayoutMenusCtrl.cs
trunk/Tools/Maestro/Maestro.Editors/WebLayout/WebLayoutSettingsCtrl.cs
trunk/Tools/Maestro/Maestro.Login/WaitCursor.cs
trunk/Tools/Maestro/Maestro.MapViewer/LegendPresenter.cs
trunk/Tools/Maestro/Maestro.Shared.UI/WaitCursor.cs
trunk/Tools/Maestro/MgCooker/Progress.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/XmlReaderBase.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Local/LocalConnection.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Native/LocalNativeConnection.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Native/LocalNativeDataReader.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Native/LocalNativeFeatureReader.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Native/LocalNativeSimpleTransform.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Native/LocalNativeSqlReader.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Feature/ReaderBase.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/PlatformConnectionBase.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Schema/ClassDefinition.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Tile/BatchSettings.cs
trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Tile/RenderThread.cs
trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/ResourceContentVersionChecker.cs
trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/WebLayout/WebLayoutInterfaces.cs
trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/WebLayout/v1_0_0/WebLayoutImpl.cs
trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/WebLayout/v1_1_0/WebLayoutImpl.cs
trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/WebLayout/v2_4_0/WebLayoutImpl.cs
trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/WebLayout/v2_6_0/WebLayoutImpl.cs
trunk/Tools/Maestro/Properties/CodeAnalysisRules.cs
Log:
#2565: More code cleanup, this one particularly focused on improper implementations of IDisposable and non-conventional events
Modified: trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsole.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsole.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/Lang/Python/PythonConsole.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -76,8 +76,33 @@
textEditor.IndentStyle = IndentStyle.None;
}
- public void Dispose() => disposedEvent.Set();
+ ~PythonConsole()
+ {
+ Dispose(false);
+ }
+ private void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ disposedEvent.Set();
+ disposedEvent?.Dispose();
+ disposedEvent = null;
+
+ inputLineReceivedEvent?.Dispose();
+ inputLineReceivedEvent = null;
+
+ lineReceivedEvent?.Dispose();
+ lineReceivedEvent = null;
+ }
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
public TextWriter Output
{
get
Modified: trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/Maestro.AddIn.Scripting/UI/IronPythonRepl.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -3,16 +3,15 @@
using Microsoft.Scripting.Hosting.Shell;
using System;
using System.Windows.Forms;
+using ICSharpCode.Core;
+using Maestro.AddIn.Scripting.Lang.Python;
namespace Maestro.AddIn.Scripting.UI
{
- using ICSharpCode.Core;
- using Lang.Python;
-
internal partial class IronPythonRepl : SingletonViewContent
{
private ITextEditor textEditor;
- private readonly PythonConsoleHost host;
+ private PythonConsoleHost host;
public IronPythonRepl()
{
@@ -42,11 +41,8 @@
public void Shutdown()
{
- if (host != null)
- {
- Console.WriteLine("Terminate python host");
- host.Terminate(0);
- }
+ Console.WriteLine("Terminate python host");
+ host?.Terminate(0);
}
protected override void OnLoad(EventArgs e)
@@ -57,27 +53,18 @@
private void OnDisposed(object sender, EventArgs e)
{
- if (host != null)
- {
- Console.WriteLine("Dispose python host");
- host.Dispose();
- }
- }
+ Console.WriteLine("Dispose python host");
+ host?.Dispose();
+ host = null;
- public override ViewRegion DefaultRegion
- {
- get
- {
- return ViewRegion.Bottom | ViewRegion.Floating;
- }
+ textEditor?.Dispose();
+ textEditor = null;
}
- private static void NewPrompt(IConsole con)
- {
- //HACK: Should be a way to get this from IronPython
- con.Write(">>> ", Microsoft.Scripting.Hosting.Shell.Style.Prompt);
- }
+ public override ViewRegion DefaultRegion => ViewRegion.Bottom | ViewRegion.Floating;
+ private static void NewPrompt(IConsole con) => con.Write(">>> ", Style.Prompt); //HACK: Should be a way to get this from IronPython
+
private void btnClear_Click(object sender, EventArgs e)
{
textEditorControl.Text = string.Empty;
Modified: trunk/Tools/Maestro/Maestro.Base/Services/OpenResourceManager.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/Services/OpenResourceManager.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/Maestro.Base/Services/OpenResourceManager.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -211,7 +211,7 @@
}
}
};
- ed.ViewContentClosing += WeakEventHandler.Wrap<CancelEventHandler>(vcClosing, (eh) => ed.ViewContentClosing -= eh);
+ ed.ViewContentClosing += WeakEventHandler.Wrap(vcClosing, (eh) => ed.ViewContentClosing -= eh);
EventHandler vcClosed = (sender, e) =>
{
//Recompute the resource key as that may have changed by a save as operation
Modified: trunk/Tools/Maestro/Maestro.Base/UI/ResourceIconCache.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/UI/ResourceIconCache.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/Maestro.Base/UI/ResourceIconCache.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -20,9 +20,8 @@
#endregion Disclaimer / License
-using OSGeo.MapGuide.MaestroAPI;
-using OSGeo.MapGuide.MaestroAPI.Resource;
using OSGeo.MapGuide.ObjectModels;
+using System;
using System.Windows.Forms;
namespace Maestro.Base.UI
@@ -30,7 +29,7 @@
/// <summary>
/// Defines a cache of icons for resource types
/// </summary>
- public interface IResourceIconCache
+ public interface IResourceIconCache : IDisposable
{
/// <summary>
/// Gets the small resource icon list
@@ -63,7 +62,7 @@
public class ResourceIconCache : IResourceIconCache
{
private ImageList _small;
- private readonly ImageList _large;
+ private ImageList _large;
private ResourceIconCache()
{
@@ -71,6 +70,28 @@
_large = new ImageList();
}
+ ~ResourceIconCache()
+ {
+ Dispose(false);
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ _small?.Dispose();
+ _small = null;
+ _large?.Dispose();
+ _large = null;
+ }
+ }
+
private const string UNKNOWN = nameof(UNKNOWN);
/// <summary>
Modified: trunk/Tools/Maestro/Maestro.Base/UI/ResourceIdNavigator.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/UI/ResourceIdNavigator.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/Maestro.Base/UI/ResourceIdNavigator.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -64,7 +64,7 @@
_omgr = omgr;
_viewMgr = viewMgr;
- _viewMgr.ViewActivated += WeakEventHandler.Wrap<Maestro.Shared.UI.ViewEventHandler>(OnViewActivated, (eh) => _viewMgr.ViewActivated -= eh);
+ _viewMgr.ViewActivated += WeakEventHandler.Wrap<ViewEventHandler>(OnViewActivated, (eh) => _viewMgr.ViewActivated -= eh);
_siteExp = siteExp;
_siteExp.ItemsSelected += WeakEventHandler.Wrap<RepositoryItemEventHandler>(OnSiteExplorerItemsSelected, (eh) => _siteExp.ItemsSelected -= eh);
Modified: trunk/Tools/Maestro/Maestro.Base/UI/ResourcePropertiesDialog.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Base/UI/ResourcePropertiesDialog.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/Maestro.Base/UI/ResourcePropertiesDialog.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -112,8 +112,16 @@
_siteExp = siteExp;
InReferenceList.SmallImageList = OutReferenceList.SmallImageList = icons.SmallImageList;
+ this.Disposed += OnDisposed;
}
+ private void OnDisposed(object sender, EventArgs e)
+ {
+ this.Disposed -= OnDisposed;
+ m_icons?.Dispose();
+ m_icons = null;
+ }
+
/// <summary>
/// Raises the System.Windows.Forms.Form.Load event
/// </summary>
Modified: trunk/Tools/Maestro/Maestro.Editors/Common/ColorComboBox.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Common/ColorComboBox.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/Maestro.Editors/Common/ColorComboBox.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -30,11 +30,12 @@
/// A combo box customised for selection of colors
/// </summary>
[Serializable]
- public class ColorComboBox
- : CustomCombo
+ public class ColorComboBox : CustomCombo
{
private bool m_allowTransparent = false;
+ [NonSerialized]
private SpecialCell m_currentColor;
+ [NonSerialized]
private ColorDialog m_colorPicker;
private static ColorDialog m_sharedColorPicker;
Modified: trunk/Tools/Maestro/Maestro.Editors/Common/Expression/FdoExpressionCompletionDataProvider.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Common/Expression/FdoExpressionCompletionDataProvider.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/Maestro.Editors/Common/Expression/FdoExpressionCompletionDataProvider.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -43,7 +43,7 @@
//NOTE/TODO:
//Auto-completions are currently case-sensitive and will only trigger on the correct case.
- internal class FdoExpressionCompletionDataProvider : ICompletionDataProvider
+ internal class FdoExpressionCompletionDataProvider : ICompletionDataProvider, IDisposable
{
private ClassDefinition _klass;
private IFdoProviderCapabilities _caps;
@@ -60,8 +60,28 @@
this.ImageList.Images.Add(Properties.Resources.funnel);
}
- public System.Windows.Forms.ImageList ImageList { get; }
+ ~FdoExpressionCompletionDataProvider()
+ {
+ Dispose(false);
+ }
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ this.ImageList?.Dispose();
+ this.ImageList = null;
+ }
+ }
+
+ public System.Windows.Forms.ImageList ImageList { get; private set; }
+
public string PreSelection { get; }
public int DefaultIndex { get; }
Modified: trunk/Tools/Maestro/Maestro.Editors/Common/ExpressionEditor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Common/ExpressionEditor.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/Maestro.Editors/Common/ExpressionEditor.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -63,8 +63,17 @@
_editor.KeyPress += OnEditorKeyPress;
_editor.DialogKeyPress += OnEditorDialogKeyPress;
_contextualBuffer = new StringBuilder();
+
+ this.Disposed += OnDisposed;
}
+ private void OnDisposed(object sender, EventArgs e)
+ {
+ this.Disposed -= OnDisposed;
+ _editor?.Dispose();
+ _editor = null;
+ }
+
/// <summary>
/// Raises the System.Windows.Forms.Form.Load event.
/// </summary>
@@ -326,8 +335,10 @@
private void ShowAutoComplete(char ch)
{
- var provider = new FdoExpressionCompletionDataProvider(_cls, _caps);
- _editor.ShowCompletionWindow(provider, ch);
+ using (var provider = new FdoExpressionCompletionDataProvider(_cls, _caps))
+ {
+ _editor.ShowCompletionWindow(provider, ch);
+ }
}
private void ColumnName_Click(object sender, EventArgs e)
Modified: trunk/Tools/Maestro/Maestro.Editors/Common/ITextEditor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Common/ITextEditor.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/Maestro.Editors/Common/ITextEditor.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -35,6 +35,7 @@
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document;
using ICSharpCode.TextEditor.Gui.CompletionWindow;
+using System;
using System.Drawing;
namespace Maestro.Editors.Common
@@ -44,7 +45,7 @@
/// all the methods will be called on another thread not the main UI thread and will therefore need to
/// be invoked.
/// </summary>
- public interface ITextEditor
+ public interface ITextEditor : IDisposable
{
/// <summary>
/// Fired when a key is pressed but before any text has been added to the text editor.
Modified: trunk/Tools/Maestro/Maestro.Editors/Common/TextEditor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Common/TextEditor.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/Maestro.Editors/Common/TextEditor.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -60,6 +60,29 @@
textEditorControl.TextEditorProperties.SupportReadOnlySegments = true;
}
+ ~TextEditorBase()
+ {
+ Dispose(false);
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ textEditorControl?.Dispose();
+ textEditorControl = null;
+
+ textArea?.Dispose();
+ textArea = null;
+ }
+ }
+
public IndentStyle IndentStyle
{
get { return textEditorControl.IndentStyle; }
@@ -245,7 +268,7 @@
/// </summary>
internal class MonoCompatibleTextEditor : TextEditorBase
{
- private readonly AutoCompletionListBox _autoBox;
+ private AutoCompletionListBox _autoBox;
private ToolTip _autoCompleteTooltip;
internal MonoCompatibleTextEditor(TextEditorControl textEditor)
@@ -255,6 +278,19 @@
_autoCompleteTooltip = new ToolTip();
}
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ _autoBox?.Dispose();
+ _autoBox = null;
+
+ _autoCompleteTooltip?.Dispose();
+ _autoCompleteTooltip = null;
+ }
+ base.Dispose(disposing);
+ }
+
private Control _parent;
public override void SetParent(Control frm)
Modified: trunk/Tools/Maestro/Maestro.Editors/FeatureSource/ExtensionsCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/FeatureSource/ExtensionsCtrl.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/Maestro.Editors/FeatureSource/ExtensionsCtrl.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -79,7 +79,7 @@
node.ToolTipText = string.Format(Strings.ExtendedClassTooltip, ext.FeatureClass);
}
};
- ext.PropertyChanged += WeakEventHandler.Wrap<PropertyChangedEventHandler>(extPropChange, (eh) => ext.PropertyChanged -= eh);
+ ext.PropertyChanged += WeakEventHandler.Wrap(extPropChange, (eh) => ext.PropertyChanged -= eh);
trvExtensions.Nodes.Add(node);
@@ -105,7 +105,7 @@
cNode.ToolTipText = calc.Expression;
}
};
- calc.PropertyChanged += WeakEventHandler.Wrap<PropertyChangedEventHandler>(calcChange, (eh) => calc.PropertyChanged -= eh);
+ calc.PropertyChanged += WeakEventHandler.Wrap(calcChange, (eh) => calc.PropertyChanged -= eh);
node.Nodes.Add(cNode);
}
@@ -127,7 +127,7 @@
jNode.Text = join.Name;
}
};
- join.PropertyChanged += WeakEventHandler.Wrap<PropertyChangedEventHandler>(joinChange, (eh) => join.PropertyChanged -= eh);
+ join.PropertyChanged += WeakEventHandler.Wrap(joinChange, (eh) => join.PropertyChanged -= eh);
node.Nodes.Add(jNode);
}
@@ -171,7 +171,7 @@
node.ToolTipText = string.Format(Strings.ExtendedClassTooltip, ext.FeatureClass);
}
};
- ext.PropertyChanged += WeakEventHandler.Wrap<PropertyChangedEventHandler>(extChange, (eh) => ext.PropertyChanged -= eh);
+ ext.PropertyChanged += WeakEventHandler.Wrap(extChange, (eh) => ext.PropertyChanged -= eh);
_fs.AddExtension(ext);
OnResourceChanged();
@@ -209,7 +209,7 @@
cNode.ToolTipText = calc.Expression;
}
};
- calc.PropertyChanged += WeakEventHandler.Wrap<PropertyChangedEventHandler>(calcChange, (eh) => calc.PropertyChanged -= eh);
+ calc.PropertyChanged += WeakEventHandler.Wrap(calcChange, (eh) => calc.PropertyChanged -= eh);
node.Nodes.Add(cNode);
node.Expand();
@@ -247,7 +247,7 @@
jNode.Text = join.Name;
}
};
- join.PropertyChanged += WeakEventHandler.Wrap<PropertyChangedEventHandler>(joinChange, (eh) => join.PropertyChanged -= eh);
+ join.PropertyChanged += WeakEventHandler.Wrap(joinChange, (eh) => join.PropertyChanged -= eh);
node.Nodes.Add(jNode);
node.Expand();
Modified: trunk/Tools/Maestro/Maestro.Editors/Fusion/MapSettingsCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Fusion/MapSettingsCtrl.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/Maestro.Editors/Fusion/MapSettingsCtrl.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -87,7 +87,7 @@
if (e.PropertyName == nameof(group.id))
item.Text = group.id;
};
- group.PropertyChanged += WeakEventHandler.Wrap<PropertyChangedEventHandler>(groupChange, (eh) => group.PropertyChanged -= eh);
+ group.PropertyChanged += WeakEventHandler.Wrap(groupChange, (eh) => group.PropertyChanged -= eh);
lstMaps.Items.Add(item);
}
Modified: trunk/Tools/Maestro/Maestro.Editors/Fusion/WidgetManagementDialog.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Fusion/WidgetManagementDialog.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/Maestro.Editors/Fusion/WidgetManagementDialog.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -112,7 +112,7 @@
if (e.PropertyName == nameof(widget.Name))
item.Name = widget.Name;
};
- widget.PropertyChanged += WeakEventHandler.Wrap<PropertyChangedEventHandler>(widgetChange, (eh) => widget.PropertyChanged -= eh);
+ widget.PropertyChanged += WeakEventHandler.Wrap(widgetChange, (eh) => widget.PropertyChanged -= eh);
_items.Add(item);
}
Modified: trunk/Tools/Maestro/Maestro.Editors/Fusion/WidgetSettingsCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/Fusion/WidgetSettingsCtrl.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/Maestro.Editors/Fusion/WidgetSettingsCtrl.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -232,7 +232,7 @@
OnResourceChanged();
}
};
- item.PropertyChanged += WeakEventHandler.Wrap<PropertyChangedEventHandler>(itemChange, (eh) => item.PropertyChanged -= eh);
+ item.PropertyChanged += WeakEventHandler.Wrap(itemChange, (eh) => item.PropertyChanged -= eh);
}
break;
@@ -259,7 +259,7 @@
OnResourceChanged();
}
};
- item.PropertyChanged += WeakEventHandler.Wrap<PropertyChangedEventHandler>(itemChange, (eh) => item.PropertyChanged -= eh);
+ item.PropertyChanged += WeakEventHandler.Wrap(itemChange, (eh) => item.PropertyChanged -= eh);
}
break;
}
Modified: trunk/Tools/Maestro/Maestro.Editors/SymbolDefinition/SymbolEditorService.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/SymbolDefinition/SymbolEditorService.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/Maestro.Editors/SymbolDefinition/SymbolEditorService.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -22,10 +22,12 @@
using Maestro.Editors.Common;
using OSGeo.MapGuide.MaestroAPI;
+using OSGeo.MapGuide.MaestroAPI.Schema;
using OSGeo.MapGuide.MaestroAPI.Services;
using OSGeo.MapGuide.ObjectModels;
using OSGeo.MapGuide.ObjectModels.SymbolDefinition;
using System;
+using System.Collections.Specialized;
namespace Maestro.Editors.SymbolDefinition
{
@@ -41,15 +43,9 @@
this.PreviewLocale = "en"; //NOXLATE
}
- public IServerConnection CurrentConnection
- {
- get { return _inner.CurrentConnection; }
- }
+ public IServerConnection CurrentConnection => _inner.CurrentConnection;
- public string SessionID
- {
- get { return _inner.SessionID; }
- }
+ public string SessionID => _inner.SessionID;
public string SuggestedSaveFolder
{
@@ -63,60 +59,31 @@
}
}
- public void RegisterCustomNotifier(INotifyResourceChanged irc)
- {
- _inner.RegisterCustomNotifier(irc);
- }
+ public void RegisterCustomNotifier(INotifyResourceChanged irc) => _inner.RegisterCustomNotifier(irc);
- public bool IsUpgradeAvailable
- {
- get { return false; }
- }
+ public bool IsUpgradeAvailable => false;
- public string SelectAnyResource()
- {
- return _inner.SelectAnyResource();
- }
+ public string SelectAnyResource() => _inner.SelectAnyResource();
- public string SelectResource(string resType)
- {
- return _inner.SelectResource(resType);
- }
+ public string SelectResource(string resType) => _inner.SelectResource(resType);
- public string SelectFolder()
- {
- return _inner.SelectFolder();
- }
+ public string SelectFolder() => _inner.SelectFolder();
public void UpdateResourceContent(string xml)
{
throw new NotSupportedException();
}
- public string SelectUnmanagedData(string startPath, System.Collections.Specialized.NameValueCollection fileTypes)
- {
- return _inner.SelectUnmanagedData(startPath, fileTypes);
- }
+ public string SelectUnmanagedData(string startPath, NameValueCollection fileTypes) => _inner.SelectUnmanagedData(startPath, fileTypes);
- public string EditExpression(string currentExpr, OSGeo.MapGuide.MaestroAPI.Schema.ClassDefinition schema, string providerName, string featureSourceId, ExpressionEditorMode mode, bool attachStylizationFunctions)
- {
- return _inner.EditExpression(currentExpr, schema, providerName, featureSourceId, mode, attachStylizationFunctions);
- }
+ public string EditExpression(string currentExpr, ClassDefinition schema, string providerName, string featureSourceId, ExpressionEditorMode mode, bool attachStylizationFunctions)
+ => _inner.EditExpression(currentExpr, schema, providerName, featureSourceId, mode, attachStylizationFunctions);
- public string ResourceID
- {
- get { return _inner.ResourceID; }
- }
+ public string ResourceID => _inner.ResourceID;
- public string EditedResourceID
- {
- get { return _inner.EditedResourceID; }
- }
+ public string EditedResourceID => _inner.EditedResourceID;
- public IResource GetEditedResource()
- {
- return _symDef;
- }
+ public IResource GetEditedResource() => _symDef;
public event System.ComponentModel.CancelEventHandler BeforeSave;
@@ -145,22 +112,13 @@
get { throw new NotImplementedException(); }
}
- public void MarkDirty()
- {
- _inner.MarkDirty();
- }
+ public void MarkDirty() => _inner.MarkDirty();
public event EventHandler DirtyStateChanged;
- public string GetCoordinateSystem()
- {
- return _inner.GetCoordinateSystem();
- }
+ public string GetCoordinateSystem() => _inner.GetCoordinateSystem();
- public void HasChanged()
- {
- _inner.HasChanged();
- }
+ public void HasChanged() => _inner.HasChanged();
public void RequestRefresh()
{
@@ -174,47 +132,24 @@
public event EventHandler Saved;
- public void SyncSessionCopy()
- {
- _inner.SyncSessionCopy();
- }
+ public void SyncSessionCopy() => _inner.SyncSessionCopy();
- public Version SiteVersion
- {
- get { return _inner.SiteVersion; }
- }
+ public Version SiteVersion => _inner.SiteVersion;
- public void OpenResource(string resourceId)
- {
- _inner.OpenResource(resourceId);
- }
+ public void OpenResource(string resourceId) => _inner.OpenResource(resourceId);
- public int[] SupportedServiceTypes
- {
- get { return _inner.SupportedServiceTypes; }
- }
+ public int[] SupportedServiceTypes => _inner.SupportedServiceTypes;
- public IService GetService(int serviceType)
- {
- return _inner.GetService(serviceType);
- }
+ public IService GetService(int serviceType) => _inner.GetService(serviceType);
- public object GetCustomProperty(string name)
- {
- return _inner.GetCustomProperty(name);
- }
+ public object GetCustomProperty(string name) => _inner.GetCustomProperty(name);
public void RunProcess(string processName, params string[] args)
{
throw new NotImplementedException();
}
- public void PrePreviewProcess()
- {
- var handler = this.BeforePreview;
- if (handler != null)
- handler(this, EventArgs.Empty);
- }
+ public void PrePreviewProcess() => this.BeforePreview?.Invoke(this, EventArgs.Empty);
public event EventHandler BeforePreview;
Modified: trunk/Tools/Maestro/Maestro.Editors/WebLayout/MenuEditorCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/WebLayout/MenuEditorCtrl.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/Maestro.Editors/WebLayout/MenuEditorCtrl.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -45,10 +45,7 @@
set { trvMenuItems.Model = value; }
}
- public override void Bind(IEditorService service)
- {
- service.RegisterCustomNotifier(this);
- }
+ public override void Bind(IEditorService service) => service.RegisterCustomNotifier(this);
protected override void UnsubscribeEventHandlers()
{
@@ -84,18 +81,15 @@
RefreshModel();
}
- private void OnCustomCommandRemoved(ICommand cmd)
+ private void OnCustomCommandRemoved(object sender, CommandEventArgs args)
{
- RemoveCustomCommandEntry(mnuCustom, cmd);
+ RemoveCustomCommandEntry(mnuCustom, args.Command);
//Might have invalidated (and removed) some menu items, so refresh
RefreshModel();
}
- private void OnCustomCommandAdded(ICommand cmd)
- {
- AddCustomCommandEntry(mnuCustom, cmd);
- }
+ private void OnCustomCommandAdded(object sender, CommandEventArgs args) => AddCustomCommandEntry(mnuCustom, args.Command);
private void InitCustomCommandMenu()
{
@@ -156,7 +150,7 @@
mi.Text = cmd.Name;
};
_customCommandListeners[mi] = handler;
- cmd.PropertyChanged += WeakEventHandler.Wrap<PropertyChangedEventHandler>(handler, (eh) => cmd.PropertyChanged -= eh);
+ cmd.PropertyChanged += WeakEventHandler.Wrap(handler, (eh) => cmd.PropertyChanged -= eh);
mi.Tag = cmd;
tsi.DropDown.Items.Add(mi);
}
@@ -211,7 +205,7 @@
trvMenuItems.Refresh();
}
};
- cmd.PropertyChanged += WeakEventHandler.Wrap<PropertyChangedEventHandler>(handler, (eh) => cmd.PropertyChanged -= eh);
+ cmd.PropertyChanged += WeakEventHandler.Wrap(handler, (eh) => cmd.PropertyChanged -= eh);
if (trvMenuItems.SelectedNode != null)
{
@@ -292,10 +286,7 @@
}
}
- private void trvMenuItems_SelectionChanged(object sender, EventArgs e)
- {
- EvaluateCommandState();
- }
+ private void trvMenuItems_SelectionChanged(object sender, EventArgs e) => EvaluateCommandState();
private void EvaluateCommandState()
{
@@ -394,9 +385,7 @@
}
private void trvMenuItems_ItemDrag(object sender, ItemDragEventArgs e)
- {
- trvMenuItems.DoDragDrop(((TreeNodeAdv[])e.Item)[0], DragDropEffects.All);
- }
+ => trvMenuItems.DoDragDrop(((TreeNodeAdv[])e.Item)[0], DragDropEffects.All);
private void trvMenuItems_DragDrop(object sender, DragEventArgs e)
{
Modified: trunk/Tools/Maestro/Maestro.Editors/WebLayout/WebLayoutMenusCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/WebLayout/WebLayoutMenusCtrl.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/Maestro.Editors/WebLayout/WebLayoutMenusCtrl.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -69,8 +69,9 @@
_wl.CommandSet.CustomCommandRemoved -= OnCommandRemoved;
}
- private void OnCommandRemoved(ICommand cmd)
+ private void OnCommandRemoved(object sender, CommandEventArgs args)
{
+ var cmd = args.Command;
if (_cmdsByName.ContainsKey(cmd.Name))
{
var dec = _cmdsByName[cmd.Name];
@@ -79,9 +80,9 @@
}
}
- private void OnCommandAdded(ICommand cmd)
+ private void OnCommandAdded(object sender, CommandEventArgs args)
{
- var dec = new CommandDecorator(cmd);
+ var dec = new CommandDecorator(args.Command);
_cmds.Add(dec);
_cmdsByName[dec.Name] = dec;
}
Modified: trunk/Tools/Maestro/Maestro.Editors/WebLayout/WebLayoutSettingsCtrl.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Editors/WebLayout/WebLayoutSettingsCtrl.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/Maestro.Editors/WebLayout/WebLayoutSettingsCtrl.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -177,10 +177,7 @@
base.UnsubscribeEventHandlers();
}
- private void chkCustomView_CheckedChanged(object sender, EventArgs e)
- {
- CheckInitialView();
- }
+ private void chkCustomView_CheckedChanged(object sender, EventArgs e) => CheckInitialView();
private void CheckInitialView()
{
@@ -191,25 +188,13 @@
_wl.Map.InitialView = null;
}
- private void chkTaskPane_CheckedChanged(object sender, EventArgs e)
- {
- numTaskPaneWidth.Enabled = chkTaskPane.Checked;
- }
+ private void chkTaskPane_CheckedChanged(object sender, EventArgs e) => numTaskPaneWidth.Enabled = chkTaskPane.Checked;
- private void CheckLeftPaneVisibility()
- {
- numInfoPaneWidth.Enabled = chkLegend.Checked || chkProperties.Checked;
- }
+ private void CheckLeftPaneVisibility() => numInfoPaneWidth.Enabled = chkLegend.Checked || chkProperties.Checked;
- private void chkLegend_CheckedChanged(object sender, EventArgs e)
- {
- CheckLeftPaneVisibility();
- }
+ private void chkLegend_CheckedChanged(object sender, EventArgs e) => CheckLeftPaneVisibility();
- private void chkProperties_CheckedChanged(object sender, EventArgs e)
- {
- CheckLeftPaneVisibility();
- }
+ private void chkProperties_CheckedChanged(object sender, EventArgs e) => CheckLeftPaneVisibility();
private void cmbHyperlinkTarget_SelectedIndexChanged(object sender, EventArgs e)
{
@@ -231,9 +216,6 @@
}
}
- private void btnShowInBrowser_Click(object sender, EventArgs e)
- {
- _edsvc.OpenUrl(txtAjaxViewerUrl.Text);
- }
+ private void btnShowInBrowser_Click(object sender, EventArgs e) => _edsvc.OpenUrl(txtAjaxViewerUrl.Text);
}
}
\ No newline at end of file
Modified: trunk/Tools/Maestro/Maestro.Login/WaitCursor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Login/WaitCursor.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/Maestro.Login/WaitCursor.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -28,8 +28,7 @@
/// <summary>
/// A class that wraps the wait cursor into a disposable class, for use with deterministic disposal
/// </summary>
- public class WaitCursor
- : IDisposable
+ public class WaitCursor : IDisposable
{
private Form m_owner = null;
private readonly Cursor m_oldcursor;
@@ -52,16 +51,30 @@
#region IDisposable Members
+ ~WaitCursor()
+ {
+ Dispose(false);
+ }
+
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
public void Dispose()
{
- //If we are the the outermost WaitCursor, reset the cursor
- if (m_owner != null && m_owner.Cursor == Cursors.WaitCursor)
+ Dispose(false);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ if (disposing)
{
- m_owner.Cursor = m_oldcursor;
- m_owner = null;
+ //If we are the the outermost WaitCursor, reset the cursor
+ if (m_owner != null && m_owner.Cursor == Cursors.WaitCursor)
+ {
+ m_owner.Cursor = m_oldcursor;
+ m_owner = null;
+ }
}
}
Modified: trunk/Tools/Maestro/Maestro.MapViewer/LegendPresenter.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.MapViewer/LegendPresenter.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/Maestro.MapViewer/LegendPresenter.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -872,11 +872,11 @@
}
Image layerIcon = null;
- if (layerMeta.IsRaster)
+ if (layerMeta.IsRaster == true)
{
layerIcon = Properties.Resources.lc_raster;
}
- else if (layerMeta.IsDwf)
+ else if (layerMeta.IsDwf == true)
{
layerIcon = Properties.Resources.lc_dwf;
}
@@ -1201,7 +1201,7 @@
/// <summary>
/// Gets whether this layer is a raster layer
/// </summary>
- public bool IsRaster
+ public bool? IsRaster
{
get
{
@@ -1214,7 +1214,7 @@
if (_isRaster.HasValue)
return _isRaster.Value;
- throw new Exception("Layer metadata not fully initialized"); //Shouldn't get to here
+ return null;
}
}
@@ -1223,7 +1223,7 @@
/// <summary>
/// Gets whether this layer is a DWF-based drawing layer
/// </summary>
- public bool IsDwf
+ public bool? IsDwf
{
get
{
@@ -1236,7 +1236,7 @@
if (_isDwf.HasValue)
return _isRaster.Value;
- throw new Exception("Layer metadata not fully initialized"); //Shouldn't get to here
+ return null;
}
}
Modified: trunk/Tools/Maestro/Maestro.Shared.UI/WaitCursor.cs
===================================================================
--- trunk/Tools/Maestro/Maestro.Shared.UI/WaitCursor.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/Maestro.Shared.UI/WaitCursor.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -29,6 +29,7 @@
/// Helper class to set a control's cursor to busy during the lifetime of this
/// object
/// </summary>
+ [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly")]
public class WaitCursor : IDisposable
{
private readonly Control _owner;
Modified: trunk/Tools/Maestro/MgCooker/Progress.cs
===================================================================
--- trunk/Tools/Maestro/MgCooker/Progress.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/MgCooker/Progress.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -136,7 +136,7 @@
if (this.InvokeRequired)
{
- ProgressCallback action = DisplayProgress;
+ TileProgressEventHandler action = DisplayProgress;
this.Invoke(action, new object[] { sender, args });
}
else
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Feature/ReaderBase.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Feature/ReaderBase.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Feature/ReaderBase.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -31,6 +31,11 @@
/// </summary>
public abstract class ReaderBase : IReader
{
+ ~ReaderBase()
+ {
+ Dispose(false);
+ }
+
/// <summary>
/// Gets the current iterated record
/// </summary>
@@ -86,10 +91,17 @@
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
- public virtual void Dispose()
+ public void Dispose()
{
+ Dispose(true);
+ GC.SuppressFinalize(this);
}
+ protected virtual void Dispose(bool disposing)
+ {
+
+ }
+
/// <summary>
/// Gets the CLR type of the field at the specified index
/// </summary>
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/PlatformConnectionBase.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/PlatformConnectionBase.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/PlatformConnectionBase.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -340,11 +340,22 @@
set { m_cachedSchemas = value; }
}
+ ~PlatformConnectionBase()
+ {
+ Dispose(false);
+ }
+
/// <summary>
/// Releases unmanaged and - optionally - managed resources
/// </summary>
- public abstract void Dispose();
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+ protected virtual void Dispose(bool disposing) { }
+
/// <summary>
/// Clones this instance.
/// </summary>
@@ -1659,38 +1670,39 @@
{
var fun = new NameValueCollection();
fun.Add("EXTENT", $"SpatialExtents(\"{geometry}\")"); //NOXLATE
- using (IReader fsr = AggregateQueryFeatureSource(resourceID, schema, filter, fun))
+ IReader fsr = null;
+ try
{
- try
+ fsr = AggregateQueryFeatureSource(resourceID, schema, filter, fun);
+ if (fsr.ReadNext())
{
- if (fsr.ReadNext())
+ if (fsr.IsNull("EXTENT")) //NOXLATE
+ throw new NullExtentException();
+
+ IGeometry geom = fsr["EXTENT"] as IGeometry; //NOXLATE
+ if (geom == null)
{
- if (fsr.IsNull("EXTENT")) //NOXLATE
- throw new NullExtentException();
-
- IGeometry geom = fsr["EXTENT"] as IGeometry; //NOXLATE
- if (geom == null)
- {
- throw new NullExtentException();
- }
- else
- {
- var env = geom.EnvelopeInternal;
- return ObjectFactory.CreateEnvelope(
- env.MinX,
- env.MinY,
- env.MaxX,
- env.MaxY);
- }
+ throw new NullExtentException();
}
else
- throw new Exception(string.Format(Strings.ErrorNoDataInResource, resourceID));
+ {
+ var env = geom.EnvelopeInternal;
+ return ObjectFactory.CreateEnvelope(
+ env.MinX,
+ env.MinY,
+ env.MaxX,
+ env.MaxY);
+ }
}
- finally
- {
- fsr.Close();
- }
+ else
+ throw new Exception(string.Format(Strings.ErrorNoDataInResource, resourceID));
}
+ finally
+ {
+ fsr?.Close();
+ fsr?.Dispose();
+ fsr = null;
+ }
}
catch
{
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Schema/ClassDefinition.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Schema/ClassDefinition.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Schema/ClassDefinition.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -35,7 +35,7 @@
///
/// Class Definitions belong to a Feature Schema
/// </summary>
- public class ClassDefinition : SchemaElement, IFdoSerializable
+ public sealed class ClassDefinition : SchemaElement, IFdoSerializable
{
private List<DataPropertyDefinition> _identity;
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Tile/BatchSettings.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Tile/BatchSettings.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Tile/BatchSettings.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -152,14 +152,14 @@
/// </summary>
/// <param name="sender"></param>
/// <param name="args"></param>
- public delegate void ProgressCallback(object sender, TileProgressEventArgs args);
+ public delegate void TileProgressEventHandler(object sender, TileProgressEventArgs args);
/// <summary>
/// This delegate is used to monitor progress on tile rendering
/// </summary>
/// <param name="sender"></param>
/// <param name="args"></param>
- public delegate void ErrorCallback(object sender, TileRenderingErrorEventArgs args);
+ public delegate void TileErrorEventHandler(object sender, TileRenderingErrorEventArgs args);
/// <summary>
/// These are the avalible states for callbacks
@@ -225,7 +225,7 @@
/// <summary>
/// Class to hold settings for a batch run of tile building
/// </summary>
- public class TilingRunCollection
+ public class TilingRunCollection : IDisposable
{
/// <summary>
/// A reference to the connection
@@ -257,57 +257,57 @@
/// <summary>
/// All maps are being rendered
/// </summary>
- public event ProgressCallback BeginRenderingMaps;
+ public event TileProgressEventHandler BeginRenderingMaps;
/// <summary>
/// A map is being rendered
/// </summary>
- public event ProgressCallback BeginRenderingMap;
+ public event TileProgressEventHandler BeginRenderingMap;
/// <summary>
/// A group is being rendered
/// </summary>
- public event ProgressCallback BeginRenderingGroup;
+ public event TileProgressEventHandler BeginRenderingGroup;
/// <summary>
/// A scale is being rendered
/// </summary>
- public event ProgressCallback BeginRenderingScale;
+ public event TileProgressEventHandler BeginRenderingScale;
/// <summary>
/// A tile is being rendered
/// </summary>
- public event ProgressCallback BeginRenderingTile;
+ public event TileProgressEventHandler BeginRenderingTile;
/// <summary>
/// All maps have been rendered
/// </summary>
- public event ProgressCallback FinishRenderingMaps;
+ public event TileProgressEventHandler FinishRenderingMaps;
/// <summary>
/// A map has been rendered
/// </summary>
- public event ProgressCallback FinishRenderingMap;
+ public event TileProgressEventHandler FinishRenderingMap;
/// <summary>
/// A group has been rendered
/// </summary>
- public event ProgressCallback FinishRenderingGroup;
+ public event TileProgressEventHandler FinishRenderingGroup;
/// <summary>
/// A scale has been rendered
/// </summary>
- public event ProgressCallback FinishRenderingScale;
+ public event TileProgressEventHandler FinishRenderingScale;
/// <summary>
/// A tile has been rendered
/// </summary>
- public event ProgressCallback FinishRenderingTile;
+ public event TileProgressEventHandler FinishRenderingTile;
/// <summary>
/// A tile has failed to render
/// </summary>
- public event ErrorCallback FailedRenderingTile;
+ public event TileErrorEventHandler FailedRenderingTile;
internal void InvokeBeginRendering(MapTilingConfiguration batchMap)
{
@@ -413,6 +413,26 @@
AddMapDefinitions(maps);
}
+ ~TilingRunCollection()
+ {
+ Dispose(false);
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ this.PauseEvent?.Dispose();
+ this.PauseEvent = null;
+ }
+ }
+
/// <summary>
/// Adds the specified map definition ids
/// </summary>
@@ -461,7 +481,7 @@
/// <param name="limit"></param>
public void LimitCols(long limit) => m_maps.ForEach(bm => bm.LimitCols(limit));
- private static void TriggerEvent(ProgressCallback evt, object sender, CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel)
+ private static void TriggerEvent(TileProgressEventHandler evt, object sender, CallbackStates state, MapTilingConfiguration map, string group, int scaleindex, int row, int column, ref bool cancel)
{
var args = new TileProgressEventArgs(state, map, group, scaleindex, row, column, cancel);
evt?.Invoke(sender, args);
@@ -819,12 +839,13 @@
//If the MaxExtents are different from the actual bounds, we need a start offset offset
- RenderThreads settings = new RenderThreads(this, m_parent, m_scaleindexmap[scaleindex], group, m_tileSetResourceID, rows, cols, rowTileOffset, colTileOffset, m_parent.Config.RandomizeTileSequence);
+ using (var settings = new RenderThreads(this, m_parent, m_scaleindexmap[scaleindex], group, m_tileSetResourceID, rows, cols, rowTileOffset, colTileOffset, m_parent.Config.RandomizeTileSequence))
+ {
+ settings.RunAndWait();
- settings.RunAndWait();
-
- if (settings.TileSet.Count != 0 && !m_parent.Cancel)
- throw new Exception(Strings.TS_ThreadFailureError);
+ if (settings.TileSet.Count != 0 && !m_parent.Cancel)
+ throw new Exception(Strings.TS_ThreadFailureError);
+ }
}
m_parent.InvokeFinishRendering(this, group, scaleindex);
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Tile/RenderThread.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Tile/RenderThread.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI/Tile/RenderThread.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -27,7 +27,7 @@
namespace OSGeo.MapGuide.MaestroAPI.Tile
{
- internal class RenderThreads
+ internal class RenderThreads : IDisposable
{
private class EventPassing
{
@@ -59,7 +59,7 @@
private readonly Queue<EventPassing> _raiseEvents = new Queue<EventPassing>();
private readonly object _syncLock;
- private readonly AutoResetEvent _event;
+ private AutoResetEvent _event;
private readonly TilingRunCollection _parent;
private readonly int _scale;
private readonly string _group;
@@ -93,6 +93,26 @@
_colOffset = colOffset;
}
+ ~RenderThreads()
+ {
+ Dispose(false);
+ }
+
+ public void Dispose()
+ {
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ _event?.Dispose();
+ _event = null;
+ }
+ }
+
public void RunAndWait()
{
ThreadPool.QueueUserWorkItem(QueueFiller);
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/HttpServerConnection.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -1563,12 +1563,15 @@
#region IDisposable Members
- public override void Dispose()
+ protected override void Dispose(bool disposing)
{
- lock (SyncRoot)
+ if (disposing)
{
- if (m_featureProviders != null)
- m_featureProviders = null;
+ lock (SyncRoot)
+ {
+ if (m_featureProviders != null)
+ m_featureProviders = null;
+ }
}
}
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/XmlReaderBase.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/XmlReaderBase.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Http/XmlReaderBase.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -169,14 +169,17 @@
base.Close();
}
- public override void Dispose()
+ protected override void Dispose(bool disposing)
{
- if (_resp != null)
+ if (disposing)
{
- ((IDisposable)_resp).Dispose();
- _resp = null;
+ if (_resp != null)
+ {
+ ((IDisposable)_resp).Dispose();
+ _resp = null;
+ }
}
- base.Dispose();
+ base.Dispose(disposing);
}
public override PropertyValueType GetPropertyType(string name)
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Local/LocalConnection.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Local/LocalConnection.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Local/LocalConnection.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -128,35 +128,23 @@
private MgdRenderingService _renderSvc;
private MgdTileService _tileSvc;
- public override void Dispose()
+ protected override void Dispose(bool disposing)
{
- if (_resSvc != null)
+ if (disposing)
{
- _resSvc.Dispose();
+ _resSvc?.Dispose();
_resSvc = null;
- }
- if (_featSvc != null)
- {
- _featSvc.Dispose();
+ _featSvc?.Dispose();
_featSvc = null;
- }
- if (_drawSvc != null)
- {
- _drawSvc.Dispose();
+ _drawSvc?.Dispose();
_drawSvc = null;
- }
- if (_renderSvc != null)
- {
- _renderSvc.Dispose();
+ _renderSvc?.Dispose();
_renderSvc = null;
- }
- if (_tileSvc != null)
- {
- _tileSvc.Dispose();
+ _tileSvc?.Dispose();
_tileSvc = null;
}
}
@@ -213,7 +201,7 @@
private void LogMethodCall(string method, bool success, params string[] values)
{
- OnRequestDispatched(method + "(" + string.Join(", ", values) + ") " + ((success) ? "Success" : "Failure"));
+ OnRequestDispatched($"{method}({string.Join(", ", values)}) {((success) ? "Success" : "Failure")}");
}
public override Stream GetResourceXmlData(string resourceID)
@@ -321,7 +309,7 @@
OnResourceAdded(newpath);
}
- public override System.IO.Stream GetResourceData(string resourceID, string dataname)
+ public override Stream GetResourceData(string resourceID, string dataname)
{
var res = GetResourceService();
//var result = Native.Utility.MgStreamToNetStream(res, res.GetType().GetMethod("GetResourceData"), new object[] { new MgResourceIdentifier(resourceID), dataname });
@@ -1140,11 +1128,18 @@
return new MgReadOnlyStream(fetch);
}
- public Stream RenderRuntimeMap(RuntimeMap map, double x, double y, double scale, int width, int height, int dpi) => this.RenderRuntimeMap(map, x, y, scale, width, height, dpi, "PNG", false);
- public Stream RenderRuntimeMap(RuntimeMap map, double x1, double y1, double x2, double y2, int width, int height, int dpi) => this.RenderRuntimeMap(map, x1, y1, x2, y2, width, height, dpi, "PNG", false);
- public Stream RenderRuntimeMap(RuntimeMap map, double x, double y, double scale, int width, int height, int dpi, string format) => this.RenderRuntimeMap(map, x, y, scale, width, height, dpi, format, false);
- public Stream RenderRuntimeMap(RuntimeMap map, double x1, double y1, double x2, double y2, int width, int height, int dpi, string format) => this.RenderRuntimeMap(map, x1, y1, x2, y2, width, height, dpi, format, false);
+ public Stream RenderRuntimeMap(RuntimeMap map, double x, double y, double scale, int width, int height, int dpi)
+ => this.RenderRuntimeMap(map, x, y, scale, width, height, dpi, "PNG", false);
+ public Stream RenderRuntimeMap(RuntimeMap map, double x1, double y1, double x2, double y2, int width, int height, int dpi)
+ => this.RenderRuntimeMap(map, x1, y1, x2, y2, width, height, dpi, "PNG", false);
+
+ public Stream RenderRuntimeMap(RuntimeMap map, double x, double y, double scale, int width, int height, int dpi, string format)
+ => this.RenderRuntimeMap(map, x, y, scale, width, height, dpi, format, false);
+
+ public Stream RenderRuntimeMap(RuntimeMap map, double x1, double y1, double x2, double y2, int width, int height, int dpi, string format)
+ => this.RenderRuntimeMap(map, x1, y1, x2, y2, width, height, dpi, format, false);
+
public Stream RenderRuntimeMap(RuntimeMap map, double x, double y, double scale, int width, int height, int dpi, string format, bool clip)
{
var impl = map as LocalRuntimeMap;
@@ -1200,7 +1195,7 @@
return new MgReadOnlyStream(fetch);
}
- public Stream RenderMapLegend(Mapping.RuntimeMap map, int width, int height, System.Drawing.Color backgroundColor, string format)
+ public Stream RenderMapLegend(RuntimeMap map, int width, int height, System.Drawing.Color backgroundColor, string format)
{
var impl = map as LocalRuntimeMap;
if (impl == null)
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Native/LocalNativeConnection.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Native/LocalNativeConnection.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Native/LocalNativeConnection.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -884,12 +884,15 @@
public bool SupportsResourcePreviews => false;
- public override void Dispose()
+ protected override void Dispose(bool disposing)
{
- if (m_con != null)
+ if (disposing)
{
- m_con.Dispose();
- m_con = null;
+ if (m_con != null)
+ {
+ m_con.Dispose();
+ m_con = null;
+ }
}
}
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Native/LocalNativeDataReader.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Native/LocalNativeDataReader.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Native/LocalNativeDataReader.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -67,34 +67,37 @@
}
}
- public override void Dispose()
+ protected override void Dispose(bool disposing)
{
- Close();
- if (_agfRw != null)
+ if (disposing)
{
- try
+ Close();
+ if (_agfRw != null)
{
- _agfRw.Dispose();
+ try
+ {
+ _agfRw.Dispose();
+ }
+ catch (MgException ex)
+ {
+ ex.Dispose();
+ }
+ _agfRw = null;
}
- catch (MgException ex)
+ if (_wktRw != null)
{
- ex.Dispose();
+ try
+ {
+ _wktRw.Dispose();
+ }
+ catch (MgException ex)
+ {
+ ex.Dispose();
+ }
+ _wktRw = null;
}
- _agfRw = null;
}
- if (_wktRw != null)
- {
- try
- {
- _wktRw.Dispose();
- }
- catch (MgException ex)
- {
- ex.Dispose();
- }
- _wktRw = null;
- }
- base.Dispose();
+ base.Dispose(disposing);
}
public override ReaderType ReaderType => ReaderType.Data;
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Native/LocalNativeFeatureReader.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Native/LocalNativeFeatureReader.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Native/LocalNativeFeatureReader.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -61,34 +61,37 @@
return (PropertyValueType)_reader.GetPropertyType(name); //We can do this because the enum values map directly to MgPropertyType
}
- public override void Dispose()
+ protected override void Dispose(bool disposing)
{
- Close();
- if (_agfRw != null)
+ if (disposing)
{
- try
+ Close();
+ if (_agfRw != null)
{
- _agfRw.Dispose();
+ try
+ {
+ _agfRw.Dispose();
+ }
+ catch (MgException ex)
+ {
+ ex.Dispose();
+ }
+ _agfRw = null;
}
- catch (MgException ex)
+ if (_wktRw != null)
{
- ex.Dispose();
+ try
+ {
+ _wktRw.Dispose();
+ }
+ catch (MgException ex)
+ {
+ ex.Dispose();
+ }
+ _wktRw = null;
}
- _agfRw = null;
}
- if (_wktRw != null)
- {
- try
- {
- _wktRw.Dispose();
- }
- catch (MgException ex)
- {
- ex.Dispose();
- }
- _wktRw = null;
- }
- base.Dispose();
+ base.Dispose(disposing);
}
public override void Close()
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Native/LocalNativeSimpleTransform.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Native/LocalNativeSimpleTransform.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Native/LocalNativeSimpleTransform.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -49,11 +49,22 @@
ty = coord.Y;
}
+ ~LocalNativeSimpleTransform()
+ {
+ Dispose(false);
+ }
+
public void Dispose()
{
- if (_trans != null)
+ Dispose(true);
+ GC.SuppressFinalize(this);
+ }
+
+ private void Dispose(bool disposing)
+ {
+ if (disposing)
{
- _trans.Dispose();
+ _trans?.Dispose();
_trans = null;
}
}
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Native/LocalNativeSqlReader.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Native/LocalNativeSqlReader.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.MaestroAPI.Native/LocalNativeSqlReader.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -44,34 +44,37 @@
public override ReaderType ReaderType => ReaderType.Sql;
- public override void Dispose()
+ protected override void Dispose(bool disposing)
{
- Close();
- if (_agfRw != null)
+ if (disposing)
{
- try
+ Close();
+ if (_agfRw != null)
{
- _agfRw.Dispose();
+ try
+ {
+ _agfRw.Dispose();
+ }
+ catch (MgException ex)
+ {
+ ex.Dispose();
+ }
+ _agfRw = null;
}
- catch (MgException ex)
+ if (_wktRw != null)
{
- ex.Dispose();
+ try
+ {
+ _wktRw.Dispose();
+ }
+ catch (MgException ex)
+ {
+ ex.Dispose();
+ }
+ _wktRw = null;
}
- _agfRw = null;
}
- if (_wktRw != null)
- {
- try
- {
- _wktRw.Dispose();
- }
- catch (MgException ex)
- {
- ex.Dispose();
- }
- _wktRw = null;
- }
- base.Dispose();
+ base.Dispose(disposing);
}
protected override IRecord ReadNextRecord()
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/ResourceContentVersionChecker.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/ResourceContentVersionChecker.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/ResourceContentVersionChecker.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -85,31 +85,32 @@
public static ResourceTypeDescriptor GetVersionFromXmlStream(Stream ms)
{
string version = "1.0.0"; //NOXLATE
- using (var xr = XmlReader.Create(ms))
+ XmlReader xr = null;
+ try
{
+ xr = XmlReader.Create(ms);
xr.MoveToContent();
if (!xr.HasAttributes)
throw new SerializationException();
- try
- {
- //Parse version number from ResourceType-x.y.z.xsd
- string xsd = xr.GetAttribute("xsi:noNamespaceSchemaLocation"); //NOXLATE
- if (xsd == null)
- return null;
+ //Parse version number from ResourceType-x.y.z.xsd
+ string xsd = xr.GetAttribute("xsi:noNamespaceSchemaLocation"); //NOXLATE
+ if (xsd == null)
+ return null;
- int start = (xsd.LastIndexOf("-")); //NOXLATE
- int end = xsd.IndexOf(".xsd") - 1; //NOXLATE
- version = xsd.Substring(start + 1, xsd.Length - end);
- string typeStr = xsd.Substring(0, start);
+ int start = (xsd.LastIndexOf("-")); //NOXLATE
+ int end = xsd.IndexOf(".xsd") - 1; //NOXLATE
+ version = xsd.Substring(start + 1, xsd.Length - end);
+ string typeStr = xsd.Substring(0, start);
- return new ResourceTypeDescriptor(typeStr, version);
- }
- finally
- {
- xr.Close();
- }
+ return new ResourceTypeDescriptor(typeStr, version);
}
+ finally
+ {
+ xr?.Close();
+ xr?.Dispose();
+ xr = null;
+ }
}
/// <summary>
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/WebLayout/WebLayoutInterfaces.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/WebLayout/WebLayoutInterfaces.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/WebLayout/WebLayoutInterfaces.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -917,10 +917,20 @@
{
}
+ public class CommandEventArgs : EventArgs
+ {
+ public CommandEventArgs(ICommand cmd)
+ {
+ this.Command = cmd;
+ }
+
+ public ICommand Command { get; }
+ }
+
/// <summary>
///
/// </summary>
- public delegate void CommandEventHandler(ICommand cmd);
+ public delegate void CommandEventHandler(object sender, CommandEventArgs args);
/// <summary>
/// The master list of viewer commands
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/WebLayout/v1_0_0/WebLayoutImpl.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/WebLayout/v1_0_0/WebLayoutImpl.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/WebLayout/v1_0_0/WebLayoutImpl.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -904,9 +904,7 @@
OnPropertyChanged(nameof(CommandSet));
if (cmd is IInvokeUrlCommand || cmd is IInvokeScriptCommand || cmd is ISearchCommand)
{
- var handler = this.CustomCommandAdded;
- if (handler != null)
- handler(cmd);
+ this.CustomCommandAdded?.Invoke(this, new CommandEventArgs(cmd));
}
}
}
@@ -920,9 +918,7 @@
OnPropertyChanged(nameof(CommandSet));
if (cmd is IInvokeUrlCommand || cmd is IInvokeScriptCommand || cmd is ISearchCommand)
{
- var handler = this.CustomCommandRemoved;
- if (handler != null)
- handler(cmd);
+ this.CustomCommandRemoved?.Invoke(this, new CommandEventArgs(cmd));
}
}
}
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/WebLayout/v1_1_0/WebLayoutImpl.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/WebLayout/v1_1_0/WebLayoutImpl.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/WebLayout/v1_1_0/WebLayoutImpl.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -905,9 +905,7 @@
OnPropertyChanged(nameof(CommandSet));
if (cmd is IInvokeUrlCommand || cmd is IInvokeScriptCommand || cmd is ISearchCommand)
{
- var handler = this.CustomCommandAdded;
- if (handler != null)
- handler(cmd);
+ this.CustomCommandAdded?.Invoke(this, new CommandEventArgs(cmd));
}
}
}
@@ -921,9 +919,7 @@
OnPropertyChanged(nameof(CommandSet));
if (cmd is IInvokeUrlCommand || cmd is IInvokeScriptCommand || cmd is ISearchCommand)
{
- var handler = this.CustomCommandRemoved;
- if (handler != null)
- handler(cmd);
+ this.CustomCommandRemoved?.Invoke(this, new CommandEventArgs(cmd));
}
}
}
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/WebLayout/v2_4_0/WebLayoutImpl.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/WebLayout/v2_4_0/WebLayoutImpl.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/WebLayout/v2_4_0/WebLayoutImpl.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -906,9 +906,7 @@
OnPropertyChanged(nameof(CommandSet));
if (cmd is IInvokeUrlCommand || cmd is IInvokeScriptCommand || cmd is ISearchCommand)
{
- var handler = this.CustomCommandAdded;
- if (handler != null)
- handler(cmd);
+ this.CustomCommandAdded?.Invoke(this, new CommandEventArgs(cmd));
}
}
}
@@ -922,9 +920,7 @@
OnPropertyChanged(nameof(CommandSet));
if (cmd is IInvokeUrlCommand || cmd is IInvokeScriptCommand || cmd is ISearchCommand)
{
- var handler = this.CustomCommandRemoved;
- if (handler != null)
- handler(cmd);
+ this.CustomCommandRemoved?.Invoke(this, new CommandEventArgs(cmd));
}
}
}
Modified: trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/WebLayout/v2_6_0/WebLayoutImpl.cs
===================================================================
--- trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/WebLayout/v2_6_0/WebLayoutImpl.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/OSGeo.MapGuide.ObjectModels/WebLayout/v2_6_0/WebLayoutImpl.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -907,9 +907,7 @@
OnPropertyChanged(nameof(CommandSet));
if (cmd is IInvokeUrlCommand || cmd is IInvokeScriptCommand || cmd is ISearchCommand)
{
- var handler = this.CustomCommandAdded;
- if (handler != null)
- handler(cmd);
+ this.CustomCommandAdded?.Invoke(this, new CommandEventArgs(cmd));
}
}
}
@@ -923,9 +921,7 @@
OnPropertyChanged(nameof(CommandSet));
if (cmd is IInvokeUrlCommand || cmd is IInvokeScriptCommand || cmd is ISearchCommand)
{
- var handler = this.CustomCommandRemoved;
- if (handler != null)
- handler(cmd);
+ this.CustomCommandRemoved?.Invoke(this, new CommandEventArgs(cmd));
}
}
}
Modified: trunk/Tools/Maestro/Properties/CodeAnalysisRules.cs
===================================================================
--- trunk/Tools/Maestro/Properties/CodeAnalysisRules.cs 2015-08-18 15:32:49 UTC (rev 8750)
+++ trunk/Tools/Maestro/Properties/CodeAnalysisRules.cs 2015-08-18 17:04:11 UTC (rev 8751)
@@ -20,6 +20,9 @@
#endregion Disclaimer / License
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times")]
+[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
+
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Redundancies in Code", "RECS0145:Removes 'private' modifiers that are not required", Justification = "The author likes to be explicit with accessibility modifiers")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Redundancies in Code", "RECS0129:Removes 'internal' modifiers that are not required", Justification = "The author likes to be explicit with accessibility modifiers")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Language", "CSE0003:Use expression-bodied members", Justification = "The author prefers debuggability over succintness")]
More information about the mapguide-commits
mailing list