151 lines
7 KiB
HTML
151 lines
7 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>CapyKit Documentation | CapyKit Documentation </title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta name="title" content="CapyKit Documentation | CapyKit Documentation ">
|
|
|
|
|
|
<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 "{query}"">
|
|
<meta name="loc:searchNoResults" content="No results for "{query}"">
|
|
<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="landing" data-yaml-mime="">
|
|
<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="">
|
|
<h1 id="capykit-documentation">CapyKit Documentation</h1>
|
|
|
|
<p>CapyKit is a small .NET utility library for the code you end up writing repeatedly: collection helpers, string and enum extensions, JSON serialization, gzip compression, password hashing, random token generation, simple key validation, distance calculations, and lightweight event reporting.</p>
|
|
<p>The library targets .NET 8 and keeps its public surface intentionally direct. Most features are static helpers or extension methods, so consuming projects can adopt one piece at a time without taking on a framework or application model.</p>
|
|
<h2 id="start-here">Start Here</h2>
|
|
<ul>
|
|
<li><a href="introduction.html">Introduction</a> explains what CapyKit includes and how the namespaces are organized.</li>
|
|
<li><a href="getting-started.html">Getting Started</a> shows installation, imports, and common usage examples.</li>
|
|
<li><a href="api/CapyKit.html">API Reference</a> contains the generated DocFX reference for every public type and member.</li>
|
|
</ul>
|
|
<h2 id="common-tasks">Common Tasks</h2>
|
|
<h3 id="work-with-strings-and-collections">Work with strings and collections</h3>
|
|
<p>Use <code>CapyKit.Extensions</code> for small quality-of-life helpers such as null fallback values, pagination, inverted filtering, left outer joins, enum display names, and property copying.</p>
|
|
<pre><code class="lang-csharp">using CapyKit.Extensions;
|
|
|
|
var displayName = user.Name.IfNullOrWhiteSpace("Guest");
|
|
var page = users.Page(pageNumber: 2, pageSize: 25);
|
|
</code></pre>
|
|
<h3 id="serialize-compress-and-restore-values">Serialize, compress, and restore values</h3>
|
|
<p>Use <code>CapyKit.Helpers.SerializationHelper</code> and <code>CapyKit.Helpers.CompressionHelper</code> when you need straightforward JSON serialization or gzip compression around serializable values.</p>
|
|
<pre><code class="lang-csharp">using CapyKit.Helpers;
|
|
|
|
var payload = SerializationHelper.SerializeToString(order);
|
|
var compressed = CompressionHelper.CompressToString(order);
|
|
var restored = CompressionHelper.Decompress<Order>(compressed);
|
|
</code></pre>
|
|
<h3 id="hash-passwords-and-generate-tokens">Hash passwords and generate tokens</h3>
|
|
<p>Use <code>SecurityHelper</code> for PBKDF2 password hashes, salts, and random values backed by .NET cryptographic random number generation.</p>
|
|
<pre><code class="lang-csharp">using CapyKit;
|
|
using CapyKit.Helpers;
|
|
|
|
Password password = SecurityHelper.Pbkdf2("correct horse battery staple");
|
|
bool matches = SecurityHelper.CompareHashedPassword(
|
|
password,
|
|
"correct horse battery staple",
|
|
password.Salt,
|
|
Password.Pbkdf2Algorithm);
|
|
</code></pre>
|
|
<h3 id="listen-to-capykit-events">Listen to CapyKit events</h3>
|
|
<p>CapyKit reports warnings and errors through <code>CapyEventReporter</code> instead of choosing a logging framework for you. Subscribe at the level your application cares about and route events into your own logging pipeline.</p>
|
|
<pre><code class="lang-csharp">using CapyKit;
|
|
|
|
CapyEventReporter.Subscribe(
|
|
e => logger.LogWarning("{Method}: {Message}", e.MethodName, e.Message),
|
|
EventLevel.Warning);
|
|
</code></pre>
|
|
<h2 id="build-the-docs-locally">Build The Docs Locally</h2>
|
|
<p>The documentation is generated with DocFX from the Markdown files in this folder and the XML comments in the <code>CapyKit</code> project.</p>
|
|
<pre><code class="lang-bash">dotnet tool install -g docfx
|
|
docfx Docs/docfx.json --serve
|
|
</code></pre>
|
|
<p>DocFX writes the generated site to <code>Docs/_site</code>.</p>
|
|
|
|
</article>
|
|
|
|
<div class="contribution d-print-none">
|
|
</div>
|
|
|
|
<div class="next-article d-print-none border-top" id="nextArticle"></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>
|