33[ ![ Latest NuGet version] ( https://img.shields.io/nuget/v/Chasm.Utilities )] ( https://www.nuget.org/packages/Chasm.Utilities/ )
44[ ![ MIT License] ( https://img.shields.io/github/license/Chasmical/Chasm )] ( ../LICENSE )
55
6- Provides various utility types and methods.
6+ Provides various utility types and methods, for code that needs to be written quickly, and not necessarily efficiently.
7+
8+ > [ !WARNING]
9+ > ████ ** Don't use this package in performance-critical scenarios!** ████
10+ > Many methods don't get inlined properly, and even if they do, there's still some overhead.
11+ > As such, appropriate uses of this library would be: writing quick tests, proofs-of-concept and mock-ups.
712
813
914
@@ -37,14 +42,14 @@ var ex = Util.Catch(doSomething, out object? result);
3742
3843``` cs
3944// Commonly written as:
40- if (a is string textA ) { /* ... */ }
41- else if (b is string textB ) { /* ... */ }
42- else if (c is string textC ) { /* ... */ }
45+ if (a is BigInteger bigInt_1 ) { /* ... */ }
46+ else if (b is BigInteger bigInt_2 ) { /* ... */ }
47+ else if (c is BigInteger bigInt_3 ) { /* ... */ }
4348
4449// Using Util.Is:
45- if (a is string text ) { /* ... */ }
46- else if (Util .Is (b , out text )) { /* ... */ }
47- else if (Util .Is (c , out text )) { /* ... */ }
50+ if (a is BigInteger bigInt ) { /* ... */ }
51+ else if (Util .Is (b , out bigInt )) { /* ... */ }
52+ else if (Util .Is (c , out bigInt )) { /* ... */ }
4853```
4954
5055` Util.With ` can be used to invoke functions while ` using ` a ` IDisposable ` :
@@ -73,7 +78,7 @@ Util.Swap(ref firstVariable, ref secondVariable);
7378
7479## ` DelegateDisposable `
7580
76- ` DelegateDisposable ` is a ` IDisposable ` interface implementation that invokes an action on disposal.
81+ ` DelegateDisposable ` is an ` IDisposable ` interface implementation that invokes an action on disposal.
7782
7883``` cs
7984store .Subscribe (listenerFunc );
@@ -86,6 +91,8 @@ var listener = DelegateDisposable.Create(
8691);
8792```
8893
94+
95+
8996## ` ReaderWriterLockSlimExtensions `
9097
9198` ReaderWriterLockSlimExtensions ` makes use of specialized variants of ` DelegateDisposable ` to enter and exit locks.
@@ -108,3 +115,5 @@ finally
108115using (rwl .WithReaderLock ())
109116 /* ... */
110117```
118+
119+
0 commit comments