Click or drag to resize

aceEventGeneralArgs Class

Home | imbSCI | imbACE | imbNLP | imbWEM | imbWBI
General imbACE Event Arguments
Inheritance Hierarchy

Namespace:  imbACE.Core.events
Assembly:  imbACE.Core (in imbACE.Core.dll) Version: 0.2
Syntax
C#
public class aceEventGeneralArgs : EventArgs
Request Example View Source

The aceEventGeneralArgs type exposes the following members.

Constructors
  NameDescription
Public methodaceEventGeneralArgs
Initializes a new instance of the aceEventGeneralArgs class
Top
Properties
  NameDescription
Public propertyisCanceled
if true, it will tell to the event handling party to try canceling / preventing, if event is preventable
Public propertyMessage
Textual message attached to the event
Public propertyOrigin
Indication on the event origin (optional)
Public propertyPath
Filesystem, network or application resources path - pointing to the position of event origin
Public propertyProperties
Additional meta data on the event
Public propertyRelatedObject
An object that is relevant to the event (not sender) - this property is not serialized
Public propertytype
Type of the event
Top
Extension Methods
  NameDescription
Public Extension MethodaceGenEx (Defined by aceExceptionTools.)
Public Extension MethodaceSciEx (Defined by aceExceptionTools.)
Top
Remarks

Try to avoid any automatic and assumption-based value attribution to the Event Arguments information

Set only data that are:

GuidelinesIn case of exception or crash: populate Properties with any useful Exception and/or contextual information for easier debugSet type and/or Origin only if it can be useful for event interpretationImplement isCanceled in case the event is yet to happen (e.g. [!:aceEventType.closing], [!:aceEventType.saving])
Examples

Recommended application of the imbACE EventGeneralArgs

// Event receiver
public class anAceObjectListener {

    public anAceObject createObject() {

        var a = new anAceObject();
        a.EventOpDone += c_operation;
        return a;
    }

    public void c_operationDone(object sender, aceEventGeneralArgs e)
    {
        // code that reacts to the event
        Environment.Exit(0);
    }

}

// Event sender
public class anAceObject {

    protected String operationName {get;set;} = "doSomething";

    // Event handler
    public event EventHandler<aceEventGeneralArgs> EventOpDone;

    // 
    protected virtual void OnOperationDone(aceEventGeneralArgs e) {

        e.Properties["OperationName"]=operationName;

        if (e.type == aceEventType.unknown) e.type = aceEventType.finished;

        EventOpDone(this, e);
    }

    // "Closed" scenario - when we know exactly what happen
    protected virtual void OnStarted() {

        var e = aceEventGeneralArgs(aceEventType.started);
        EventOpDone(this, e);

    }

}
See Also