Class CancellableEventArgs
Represents event data for events that support cancellation.
Inheritance
Namespace: Umbraco.Cms.Core.Events
Assembly: Umbraco.Core.dll
Syntax
public class CancellableEventArgs : EventArgs
Constructors
View SourceCancellableEventArgs()
Initializes a new instance of the CancellableEventArgs class with cancellation enabled.
Declaration
public CancellableEventArgs()
CancellableEventArgs(bool)
Initializes a new instance of the CancellableEventArgs class.
Declaration
public CancellableEventArgs(bool canCancel)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | canCancel | A value indicating whether the event can be cancelled. |
CancellableEventArgs(bool, EventMessages)
Initializes a new instance of the CancellableEventArgs class.
Declaration
public CancellableEventArgs(bool canCancel, EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | canCancel | A value indicating whether the event can be cancelled. |
| EventMessages | eventMessages | The event messages. |
CancellableEventArgs(bool, EventMessages, IDictionary<string, object>)
Initializes a new instance of the CancellableEventArgs class.
Declaration
public CancellableEventArgs(bool canCancel, EventMessages messages, IDictionary<string, object> additionalData)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | canCancel | A value indicating whether the event can be cancelled. |
| EventMessages | messages | The event messages. |
| IDictionary<string, object> | additionalData | Additional data associated with the event. |
CancellableEventArgs(EventMessages)
Initializes a new instance of the CancellableEventArgs class with cancellation enabled.
Declaration
public CancellableEventArgs(EventMessages eventMessages)
Parameters
| Type | Name | Description |
|---|---|---|
| EventMessages | eventMessages | The event messages. |
Properties
View SourceAdditionalData
In some cases raised evens might need to contain additional arbitrary readonly data which can be read by event subscribers
Declaration
public ReadOnlyDictionary<string, object> AdditionalData { get; set; }
Property Value
| Type | Description |
|---|---|
| ReadOnlyDictionary<string, object> |
Remarks
This allows for a bit of flexibility in our event raising - it's not pretty but we need to maintain backwards compatibility so we cannot change the strongly typed nature for some events.
CanCancel
Flag to determine if this instance will support being cancellable
Declaration
public bool CanCancel { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Cancel
If this instance supports cancellation, this gets/sets the cancel value
Declaration
public bool Cancel { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
EventState
This can be used by event subscribers to store state in the event args so they easily deal with custom state data between a starting ("ing") event and an ending ("ed") event
Declaration
public IDictionary<string, object> EventState { get; set; }
Property Value
| Type | Description |
|---|---|
| IDictionary<string, object> |
Messages
Returns the EventMessages object which is used to add messages to the message collection for this event
Declaration
public EventMessages Messages { get; }
Property Value
| Type | Description |
|---|---|
| EventMessages |
Methods
View SourceCancelOperation(EventMessage)
if this instance supports cancellation, this will set Cancel to true with an affiliated cancellation message
Declaration
public void CancelOperation(EventMessage cancelationMessage)
Parameters
| Type | Name | Description |
|---|---|---|
| EventMessage | cancelationMessage |
Equals(object?)
Declaration
public override bool Equals(object? obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj |
Returns
| Type | Description |
|---|---|
| bool |
Equals(CancellableEventArgs?)
Declaration
public bool Equals(CancellableEventArgs? other)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellableEventArgs | other |
Returns
| Type | Description |
|---|---|
| bool |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int |
Operators
View Sourceoperator ==(CancellableEventArgs?, CancellableEventArgs?)
Determines whether two CancellableEventArgs instances are equal.
Declaration
public static bool operator ==(CancellableEventArgs? left, CancellableEventArgs? right)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellableEventArgs | left | The first instance to compare. |
| CancellableEventArgs | right | The second instance to compare. |
Returns
| Type | Description |
|---|---|
| bool |
|
operator !=(CancellableEventArgs, CancellableEventArgs)
Determines whether two CancellableEventArgs instances are not equal.
Declaration
public static bool operator !=(CancellableEventArgs left, CancellableEventArgs right)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellableEventArgs | left | The first instance to compare. |
| CancellableEventArgs | right | The second instance to compare. |
Returns
| Type | Description |
|---|---|
| bool |
|