Class CapyEventReporter

Namespace
CapyKit
Assembly
CapyKit.dll

The CapyEventReporter class is responsible for managing event subscriptions and emissions within CapyKit.

public static class CapyEventReporter
Inheritance
CapyEventReporter
Inherited Members

Remarks

Because consumers of CapyKit may have varied ways of handling logging, the CapyEventReporter provides a way for subscribers to recieve events for various "events" within the library. These can be thought of as a logging solution for CapyKit. Consumers are free to treat these events however they see fit.

Methods

EmitEvent(EventLevel, string, string, params object[])

Emits an event with the given severity level, message, and method name.

public static void EmitEvent(EventLevel eventLevel, string message, string method = null, params object[] args)

Parameters

eventLevel EventLevel

The severity level of the event.

message string

The message describing the reason for the event. String formatting for args is accepted.

method string

(Optional) The name of the method where the event was raised.

args object[]

A variable-length parameters list containing arguments for formatting the message.

Examples

CapyEventReporter.EmitEvent(EventLevel.Error, "Could not find the description for {0}.", args: new[] { enumeration });

Remarks

In order to allow for efficient calling member access via CallerMemberNameAttribute , it is suggested that args is defined explicitly for formatted messages.

See Also

EmitEventOnce(EventLevel, string, string, string, params object[])

Emits an event with the given severity level, message, unique identifier, and method name one time.

public static void EmitEventOnce(EventLevel eventLevel, string message, string uniqueIdentifier, string method = null, params object[] args)

Parameters

eventLevel EventLevel

The severity level of the event.

message string

The message describing the reason for the event. String formatting for args is accepted.

uniqueIdentifier string

A unique identifier for the event emission.

method string

(Optional) The name of the method where the event was raised.

args object[]

A variable-length parameters list containing arguments for formatting the message.

Remarks

This method is similar to EmitEvent(EventLevel, string, string, string, object[]) , but requires a unique identifier (such as a Guid) to prevent duplicate emissions.

See Also

Subscribe(CapyEventHandler, EventLevel, string)

Subscribes the specified event handler to the event with the given subscription level and origin.

public static void Subscribe(CapyEventHandler callback, EventLevel subscriptionLevel, string origin = null)

Parameters

callback CapyEventHandler

The event handler to subscribe.

subscriptionLevel EventLevel

The severity level of the event to subscribe to.

origin string

(Optional) The name of the method or class where the subscription is made.

Remarks

If there is no existing list for the given subscription level, a new list is created and added to the dictionary.

Unsubscribe(CapyEventHandler, string)

Unsubscribes the specified event handler from the event with the given origin.

public static void Unsubscribe(CapyEventHandler callback, string origin)

Parameters

callback CapyEventHandler

The event handler to unsubscribe.

origin string

The name of the method or class where the subscription was made.