CapyKit/Docs/_site/api/CapyKit.CapyEventReporter.html

366 lines
14 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Class CapyEventReporter | CapyKit Documentation </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="title" content="Class CapyEventReporter | CapyKit Documentation ">
<meta name="description" content="The CapyEventReporter class is responsible for managing event subscriptions and emissions within CapyKit.">
<link rel="icon" href="../favicon.ico">
<link rel="stylesheet" href="../public/docfx.min.css">
<link rel="stylesheet" href="../public/main.css">
<meta name="docfx:navrel" content="../toc.html">
<meta name="docfx:tocrel" content="../toc.html">
<meta name="docfx:rel" content="../">
<meta name="loc:inThisArticle" content="In this article">
<meta name="loc:searchResultsCount" content="{count} results for &quot;{query}&quot;">
<meta name="loc:searchNoResults" content="No results for &quot;{query}&quot;">
<meta name="loc:tocFilter" content="Filter by title">
<meta name="loc:nextArticle" content="Next">
<meta name="loc:prevArticle" content="Previous">
<meta name="loc:themeLight" content="Light">
<meta name="loc:themeDark" content="Dark">
<meta name="loc:themeAuto" content="Auto">
<meta name="loc:changeTheme" content="Change theme">
<meta name="loc:copy" content="Copy">
<meta name="loc:downloadPdf" content="Download PDF">
<script type="module" src="./../public/docfx.min.js"></script>
<script>
const theme = localStorage.getItem('theme') || 'auto'
document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
</script>
</head>
<body class="tex2jax_ignore" data-layout="" data-yaml-mime="ManagedReference">
<header class="bg-body border-bottom">
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
<div class="container-xxl flex-nowrap">
<a class="navbar-brand" href="../index.html">
<img id="logo" class="svg" src="../logo.svg" alt="CapyKit Documentation">
CapyKit Documentation
</a>
<button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
<i class="bi bi-three-dots"></i>
</button>
<div class="collapse navbar-collapse" id="navpanel">
<div id="navbar">
<form class="search" role="search" id="search">
<i class="bi bi-search"></i>
<input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search">
</form>
</div>
</div>
</div>
</nav>
</header>
<main class="container-xxl">
<div class="content">
<div class="actionbar">
<nav id="breadcrumb"></nav>
</div>
<article data-uid="CapyKit.CapyEventReporter">
<h1 id="CapyKit_CapyEventReporter" data-uid="CapyKit.CapyEventReporter" class="text-break">
Class CapyEventReporter
</h1>
<div class="facts text-secondary">
<dl><dt>Namespace</dt><dd><a class="xref" href="CapyKit.html">CapyKit</a></dd></dl>
<dl><dt>Assembly</dt><dd>CapyKit.dll</dd></dl>
</div>
<div class="markdown summary"><p>The CapyEventReporter class is responsible for managing event subscriptions and emissions within CapyKit.</p>
</div>
<div class="markdown conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static class CapyEventReporter</code></pre>
</div>
<dl class="typelist inheritance">
<dt>Inheritance</dt>
<dd>
<div><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></div>
<div><span class="xref">CapyEventReporter</span></div>
</dd>
</dl>
<dl class="typelist inheritedMembers">
<dt>Inherited Members</dt>
<dd>
<div>
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object)</a>
</div>
<div>
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object, object)</a>
</div>
<div>
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a>
</div>
<div>
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>
</div>
<div>
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone">object.MemberwiseClone()</a>
</div>
<div>
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object, object)</a>
</div>
<div>
<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a>
</div>
</dd></dl>
<h2 id="CapyKit_CapyEventReporter_remarks">Remarks</h2>
<div class="markdown level0 remarks"><p>Because consumers of CapyKit may have varied ways of handling logging, the <a class="xref" href="CapyKit.CapyEventReporter.html">CapyEventReporter</a> provides
a way for subscribers to recieve events for various &quot;events&quot; 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.</p>
</div>
<h2 class="section" id="methods">Methods
</h2>
<a id="CapyKit_CapyEventReporter_EmitEvent_" data-uid="CapyKit.CapyEventReporter.EmitEvent*"></a>
<h3 id="CapyKit_CapyEventReporter_EmitEvent_CapyKit_EventLevel_System_String_System_String_System_Object___" data-uid="CapyKit.CapyEventReporter.EmitEvent(CapyKit.EventLevel,System.String,System.String,System.Object[])">
EmitEvent(EventLevel, string, string, params object[])
</h3>
<div class="markdown level1 summary"><p>Emits an event with the given severity level, message, and method name.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static void EmitEvent(EventLevel eventLevel, string message, string method = null, params object[] args)</code></pre>
</div>
<h4 class="section">Parameters</h4>
<dl class="parameters">
<dt><code>eventLevel</code> <a class="xref" href="CapyKit.EventLevel.html">EventLevel</a></dt>
<dd><p>The severity level of the event.</p>
</dd>
<dt><code>message</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
<dd><p>The message describing the reason for the event. String formatting for <code class="paramref">args</code>
is accepted.</p>
</dd>
<dt><code>method</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
<dd><p>(Optional) The name of the method where the event was raised.</p>
</dd>
<dt><code>args</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a>[]</dt>
<dd><p>A variable-length parameters list containing arguments for formatting the message.</p>
</dd>
</dl>
<h4 class="section" id="CapyKit_CapyEventReporter_EmitEvent_CapyKit_EventLevel_System_String_System_String_System_Object____examples">Examples</h4>
<pre><code class="lang-csharp">CapyEventReporter.EmitEvent(EventLevel.Error, "Could not find the description for {0}.", args: new[] { enumeration });</code></pre>
<h4 class="section" id="CapyKit_CapyEventReporter_EmitEvent_CapyKit_EventLevel_System_String_System_String_System_Object____remarks">Remarks</h4>
<div class="markdown level1 remarks"><p>In order to allow for efficient calling member access via <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.runtime.compilerservices.callermembernameattribute">CallerMemberNameAttribute</a>
, it is suggested that <code class="paramref">args</code> is defined explicitly for formatted messages.</p>
</div>
<dl class="typelist seealso">
<dt>See Also</dt>
<dd>
<div><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.runtime.compilerservices.callermembernameattribute">CallerMemberNameAttribute</a></div>
</dd>
</dl>
<a id="CapyKit_CapyEventReporter_EmitEventOnce_" data-uid="CapyKit.CapyEventReporter.EmitEventOnce*"></a>
<h3 id="CapyKit_CapyEventReporter_EmitEventOnce_CapyKit_EventLevel_System_String_System_String_System_String_System_Object___" data-uid="CapyKit.CapyEventReporter.EmitEventOnce(CapyKit.EventLevel,System.String,System.String,System.String,System.Object[])">
EmitEventOnce(EventLevel, string, string, string, params object[])
</h3>
<div class="markdown level1 summary"><p>Emits an event with the given severity level, message, unique identifier, and method name one
time.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static void EmitEventOnce(EventLevel eventLevel, string message, string uniqueIdentifier, string method = null, params object[] args)</code></pre>
</div>
<h4 class="section">Parameters</h4>
<dl class="parameters">
<dt><code>eventLevel</code> <a class="xref" href="CapyKit.EventLevel.html">EventLevel</a></dt>
<dd><p>The severity level of the event.</p>
</dd>
<dt><code>message</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
<dd><p>The message describing the reason for the event. String formatting for <code class="paramref">args</code>
is accepted.</p>
</dd>
<dt><code>uniqueIdentifier</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
<dd><p>A unique identifier for the event emission.</p>
</dd>
<dt><code>method</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
<dd><p>(Optional) The name of the method where the event was raised.</p>
</dd>
<dt><code>args</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a>[]</dt>
<dd><p>A variable-length parameters list containing arguments for formatting the message.</p>
</dd>
</dl>
<h4 class="section" id="CapyKit_CapyEventReporter_EmitEventOnce_CapyKit_EventLevel_System_String_System_String_System_String_System_Object____remarks">Remarks</h4>
<div class="markdown level1 remarks"><p>This method is similar to EmitEvent(EventLevel, string, string, string, object[])
, but requires a unique identifier (such as a <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.guid">Guid</a>) to prevent duplicate
emissions.</p>
</div>
<dl class="typelist seealso">
<dt>See Also</dt>
<dd>
<div><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.runtime.compilerservices.callermembernameattribute">CallerMemberNameAttribute</a></div>
<div><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.guid">Guid</a></div>
</dd>
</dl>
<a id="CapyKit_CapyEventReporter_Subscribe_" data-uid="CapyKit.CapyEventReporter.Subscribe*"></a>
<h3 id="CapyKit_CapyEventReporter_Subscribe_CapyKit_CapyEventHandler_CapyKit_EventLevel_System_String_" data-uid="CapyKit.CapyEventReporter.Subscribe(CapyKit.CapyEventHandler,CapyKit.EventLevel,System.String)">
Subscribe(CapyEventHandler, EventLevel, string)
</h3>
<div class="markdown level1 summary"><p>Subscribes the specified event handler to the event with the given subscription level and
origin.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static void Subscribe(CapyEventHandler callback, EventLevel subscriptionLevel, string origin = null)</code></pre>
</div>
<h4 class="section">Parameters</h4>
<dl class="parameters">
<dt><code>callback</code> <a class="xref" href="CapyKit.CapyEventHandler.html">CapyEventHandler</a></dt>
<dd><p>The event handler to subscribe.</p>
</dd>
<dt><code>subscriptionLevel</code> <a class="xref" href="CapyKit.EventLevel.html">EventLevel</a></dt>
<dd><p>The severity level of the event to subscribe to.</p>
</dd>
<dt><code>origin</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
<dd><p>(Optional) The name of the method or class where the subscription is made.</p>
</dd>
</dl>
<h4 class="section" id="CapyKit_CapyEventReporter_Subscribe_CapyKit_CapyEventHandler_CapyKit_EventLevel_System_String__remarks">Remarks</h4>
<div class="markdown level1 remarks"><p>If there is no existing list for the given subscription level, a new list is created and
added to the dictionary.</p>
</div>
<a id="CapyKit_CapyEventReporter_Unsubscribe_" data-uid="CapyKit.CapyEventReporter.Unsubscribe*"></a>
<h3 id="CapyKit_CapyEventReporter_Unsubscribe_CapyKit_CapyEventHandler_System_String_" data-uid="CapyKit.CapyEventReporter.Unsubscribe(CapyKit.CapyEventHandler,System.String)">
Unsubscribe(CapyEventHandler, string)
</h3>
<div class="markdown level1 summary"><p>Unsubscribes the specified event handler from the event with the given origin.</p>
</div>
<div class="markdown level1 conceptual"></div>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public static void Unsubscribe(CapyEventHandler callback, string origin)</code></pre>
</div>
<h4 class="section">Parameters</h4>
<dl class="parameters">
<dt><code>callback</code> <a class="xref" href="CapyKit.CapyEventHandler.html">CapyEventHandler</a></dt>
<dd><p>The event handler to unsubscribe.</p>
</dd>
<dt><code>origin</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></dt>
<dd><p>The name of the method or class where the subscription was made.</p>
</dd>
</dl>
</article>
<div class="contribution d-print-none">
</div>
</div>
<div class="affix">
<nav id="affix"></nav>
</div>
</main>
<div class="container-xxl search-results" id="search-results"></div>
<footer class="border-top text-secondary">
<div class="container-xxl">
<div class="flex-fill">
<span>Made with <a href="https://dotnet.github.io/docfx">docfx</a></span>
</div>
</div>
</footer>
</body>
</html>