Class CapyEventReporter
The CapyEventReporter class is responsible for managing event subscriptions and emissions within CapyKit.
Namespace: CapyKit
Assembly: CapyKit.dll
Syntax
public static class CapyEventReporter
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.
Declaration
public static void EmitEvent(EventLevel eventLevel, string message, string method = null, params object[] args)
Parameters
| Type | Name | Description |
|---|---|---|
| EventLevel | eventLevel | The severity level of the event. |
| string | message | The message describing the reason for the event. String formatting for |
| string | method | (Optional) The name of the method where the event was raised. |
| object[] | args | A variable-length parameters list containing arguments for formatting the message. |
Remarks
In order to allow for efficient calling member access via CallerMemberNameAttribute
, it is suggested that args is defined explicitly for formatted messages.
Examples
CapyEventReporter.EmitEvent(EventLevel.Error, "Could not find the description for {0}.", args: new[] { enumeration });
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.
Declaration
public static void EmitEventOnce(EventLevel eventLevel, string message, string uniqueIdentifier, string method = null, params object[] args)
Parameters
| Type | Name | Description |
|---|---|---|
| EventLevel | eventLevel | The severity level of the event. |
| string | message | The message describing the reason for the event. String formatting for |
| string | uniqueIdentifier | A unique identifier for the event emission. |
| string | method | (Optional) The name of the method where the event was raised. |
| object[] | args | 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.
Declaration
public static void Subscribe(CapyEventHandler callback, EventLevel subscriptionLevel, string origin = null)
Parameters
| Type | Name | Description |
|---|---|---|
| CapyEventHandler | callback | The event handler to subscribe. |
| EventLevel | subscriptionLevel | The severity level of the event to subscribe to. |
| string | origin | (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.
Declaration
public static void Unsubscribe(CapyEventHandler callback, string origin)
Parameters
| Type | Name | Description |
|---|---|---|
| CapyEventHandler | callback | The event handler to unsubscribe. |
| string | origin | The name of the method or class where the subscription was made. |