From 94f69d50073d32179ec5ef2d00929f251f1a4cbb Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Sat, 15 Dec 2012 21:41:09 +0500 Subject: [PATCH] Removed ICancellableObjectEventArgs and instead just have a base class without the strongly typed object... CancellableEventArgs. --- .../Events/CancellableEventArgs.cs | 51 +++++++++++++++++++ .../Events/CancellableObjectEventArgs.cs | 33 +----------- src/Umbraco.Core/Events/EventExtensions.cs | 2 +- .../Events/ICancellableObjectEventArgs.cs | 18 ------- src/Umbraco.Core/Umbraco.Core.csproj | 2 +- 5 files changed, 55 insertions(+), 51 deletions(-) create mode 100644 src/Umbraco.Core/Events/CancellableEventArgs.cs delete mode 100644 src/Umbraco.Core/Events/ICancellableObjectEventArgs.cs diff --git a/src/Umbraco.Core/Events/CancellableEventArgs.cs b/src/Umbraco.Core/Events/CancellableEventArgs.cs new file mode 100644 index 0000000000..80e69ae353 --- /dev/null +++ b/src/Umbraco.Core/Events/CancellableEventArgs.cs @@ -0,0 +1,51 @@ +using System; +using System.Security.Permissions; + +namespace Umbraco.Core.Events +{ + /// + /// Event args for that can support cancellation + /// + [HostProtection(SecurityAction.LinkDemand, SharedState = true)] + public class CancellableEventArgs : EventArgs + { + private bool _cancel; + + public CancellableEventArgs(bool canCancel) + { + CanCancel = canCancel; + } + + public CancellableEventArgs() + : this(true) + { + } + /// + /// Flag to determine if this instance will support being cancellable + /// + public bool CanCancel { get; set; } + + /// + /// If this instance supports cancellation, this gets/sets the cancel value + /// + public bool Cancel + { + get + { + if (!CanCancel) + { + throw new InvalidOperationException("This event argument class does not support cancelling."); + } + return _cancel; + } + set + { + if (!CanCancel) + { + throw new InvalidOperationException("This event argument class does not support cancelling."); + } + _cancel = value; + } + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Events/CancellableObjectEventArgs.cs b/src/Umbraco.Core/Events/CancellableObjectEventArgs.cs index b4efcca229..736f8c4361 100644 --- a/src/Umbraco.Core/Events/CancellableObjectEventArgs.cs +++ b/src/Umbraco.Core/Events/CancellableObjectEventArgs.cs @@ -1,4 +1,3 @@ -using System; using System.Security.Permissions; using Umbraco.Core.Models; using Umbraco.Core.Models.EntityBase; @@ -10,14 +9,13 @@ namespace Umbraco.Core.Events /// /// [HostProtection(SecurityAction.LinkDemand, SharedState = true)] - public class CancellableObjectEventArgs : EventArgs, ICancellableObjectEventArgs + public class CancellableObjectEventArgs : CancellableEventArgs { - private bool _cancel; public CancellableObjectEventArgs(T entity, bool canCancel) + : base(canCancel) { Entity = entity; - CanCancel = canCancel; } public CancellableObjectEventArgs(T entity) @@ -25,33 +23,6 @@ namespace Umbraco.Core.Events { } - /// - /// Flag to determine if this instance will support being cancellable - /// - public bool CanCancel { get; set; } - - /// - /// If this instance supports cancellation, this gets/sets the cancel value - /// - public bool Cancel - { - get - { - if (!CanCancel) - { - throw new InvalidOperationException("This event argument class does not support cancelling."); - } - return _cancel; - } - set - { - if (!CanCancel) - { - throw new InvalidOperationException("This event argument class does not support cancelling."); - } - _cancel = value; - } - } public T Entity { get; private set; } diff --git a/src/Umbraco.Core/Events/EventExtensions.cs b/src/Umbraco.Core/Events/EventExtensions.cs index 60a823a725..99cf145fe0 100644 --- a/src/Umbraco.Core/Events/EventExtensions.cs +++ b/src/Umbraco.Core/Events/EventExtensions.cs @@ -20,7 +20,7 @@ namespace Umbraco.Core.Events this TypedEventHandler eventHandler, TArgs args, TSender sender) - where TArgs : ICancellableObjectEventArgs + where TArgs : CancellableEventArgs { if (eventHandler != null) eventHandler(sender, args); diff --git a/src/Umbraco.Core/Events/ICancellableObjectEventArgs.cs b/src/Umbraco.Core/Events/ICancellableObjectEventArgs.cs deleted file mode 100644 index 871362d9db..0000000000 --- a/src/Umbraco.Core/Events/ICancellableObjectEventArgs.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace Umbraco.Core.Events -{ - /// - /// Interface for EventArgs clases to implement when they support cancelling operations - /// - public interface ICancellableObjectEventArgs - { - /// - /// If this instance supports cancellation, this gets/sets the cancel value - /// - bool Cancel { get; set; } - - /// - /// Flag to determine if this instance will support being cancellable - /// - bool CanCancel { get; set; } - } -} \ No newline at end of file diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index 909e74b89b..10487ee9ba 100644 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -117,12 +117,12 @@ + -