VOOZH about

URL: https://www.nuget.org/packages/Plinth.Common/

⇱ NuGet Gallery | Plinth.Common 1.8.1




👁 Image
Plinth.Common 1.8.1

Prefix Reserved
dotnet add package Plinth.Common --version 1.8.1
 
 
NuGet\Install-Package Plinth.Common -Version 1.8.1
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Plinth.Common" Version="1.8.1" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Plinth.Common" Version="1.8.1" />
 
Directory.Packages.props
<PackageReference Include="Plinth.Common" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Plinth.Common --version 1.8.1
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Plinth.Common, 1.8.1"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Plinth.Common@1.8.1
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Plinth.Common&version=1.8.1
 
Install as a Cake Addin
#tool nuget:?package=Plinth.Common&version=1.8.1
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

README

Plinth.Common

A set of generic utilities, extensions, and enhancements for dotnet applications

Cache

Extensions for atomic GetOrCreate on Microsoft.Extensions.Caching.Memory memory caches Example:

IMemoryCache memCache = MemoryCacheUtil.Create();
await memCache.GetOrCreateAtomicMaxDurationAsync(
	"key", TimeSpan.FromMinutes(2), async () => await LoadValue());

👉 MemoryCacheUtil.Create() is a shorthand method for creating a new IMemoryCache.

Collections

  • Case Insensitive Dictionary and HashSet
  • Default Dictionary that will supply a default value for a key when requested
  • Examples:
// values are case insensitive
var set = new CaseInsensitiveHashSet<string>() { "abc", "ABC" };
set.Contains("aBc"); // true

// LINQ extension
var set = items.Where(...).Select(...).ToCaseInsensitiveHashSet();

// keys are case insensitive
var dict = new CaseInsensitiveDictionary<string, int>() { ["abc"] = 5 };
dict["ABC"]; // 5
dict.ContainsKey("aBc"); // true

// LINQ extension
var dict = items.Where(...).Select(...).ToCaseInsensitiveDictionary(v => v.ID);

// default dictionary, easy counting
var dict = new DefaultDictionary<string, int>(0);
dict["a"]++; // dict["a"] now is 1

// default dictionary, easy multi maps
var dict = new DefaultDictionary<string, ISet<int>>(() => new HashSet<int>());
dict["a"].Add(7); // "a" has a set with (7) in it

Constants

Handy constants for Content Types ContentTypes.ApplicationJson"application/json; charset=utf-8"

Exceptions

Logical exceptions for common API return values. Allows for separation between logic and api projects

  • LogicalBadRequestException
  • LogicalConflictException
  • LogicalForbiddenException
  • LogicalNotFoundException
  • LogicalPreconditionFailedException

Extensions

A variety of useful extensions to common classes

  • For manipulating DataRow
  • IDictionary .GetValueOrDefault()
  • IEnumerable .IsNullOrEmpty() and .Many()
  • Enum extensions for converting between enums by name (not by integer value)
  • ILogger extensions for logging code durations
using (log.LogExecTiming("some code"))
{
	... some code ...
	log.Debug("action");
}
// logs
[CTX-6540F] : Starting some code #52400089
[CTX-6540F] : action
[CTX-6540F] : some code #52400089 Took: 00.00.00.274472
  • Sensitive data extensions for masking secure items like passwords, SSNs, and credit card numbers.
  • Stream extensions .ToBytes() and .ToBytesAsync()
  • String extensions for converting strings to various types, .ChangeType<T>() as various .To{Type}OrNull()

Logging

  • Extensions and enhancements to Microsoft.Extensions.ILogger for better tracing when using the Plinth ecosystem
  • Provides StaticLogManager.GetLogger() to retrieve a static logger for the current class
  • Provides RequestTraceId and RequestTraceProperties singletons for passing data through the entire call stack (including across HTTP boundaries)
  • Adds shorthand calls for shorter log function names.
    • LogTraceTrace
    • LogDebugDebug
    • LogInformationInfo
    • LogWarningWarn
    • LogErrorError
    • LogCriticalCritical or Fatal

Mapping

An enhanced version of Omu.ValueInjecter for easy object to object mapping Allows for deeply nested Field to Field mapping (including Lists, Sets, and Dictionaries)

Utils

A set of static utilities

  • AsyncUtil: Some async utilities, mostly obsolete as of net6.0
  • DateTimeUtil: Utilities for truncating date times, UTC/TZ conversions, and some date comparison functions
  • HexUtil: Conversion of hex strings to bytes and vice versa. 👉 Obsolete as of .NET 9.0 or greater - Use Convert.ToHexStringLower() and Convert.FromHexString() instead. HexUtil methods still function on .NET 8.0 and earlier.
  • RuntimeUtil: Provides FindExecutableHome() which can find your project root at runtime
  • TimeUtil: Provides log timing (used by ILogger extension noted above)
  • UriUtil: Provides a Join() method similar to Path.Combine()
Product Versions Compatible and additional computed target framework versions.
.NET net8.0 net8.0 is compatible.  net8.0-android net8.0-android was computed.  net8.0-browser net8.0-browser was computed.  net8.0-ios net8.0-ios was computed.  net8.0-maccatalyst net8.0-maccatalyst was computed.  net8.0-macos net8.0-macos was computed.  net8.0-tvos net8.0-tvos was computed.  net8.0-windows net8.0-windows was computed.  net9.0 net9.0 is compatible.  net9.0-android net9.0-android was computed.  net9.0-browser net9.0-browser was computed.  net9.0-ios net9.0-ios was computed.  net9.0-maccatalyst net9.0-maccatalyst was computed.  net9.0-macos net9.0-macos was computed.  net9.0-tvos net9.0-tvos was computed.  net9.0-windows net9.0-windows was computed.  net10.0 net10.0 is compatible.  net10.0-android net10.0-android was computed.  net10.0-browser net10.0-browser was computed.  net10.0-ios net10.0-ios was computed.  net10.0-maccatalyst net10.0-maccatalyst was computed.  net10.0-macos net10.0-macos was computed.  net10.0-tvos net10.0-tvos was computed.  net10.0-windows net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (18)

Showing the top 5 NuGet packages that depend on Plinth.Common:

Package Downloads
Plinth.Serialization

JSON/XML/etc object serialization

Plinth.Security

Security, Cryptography, and Token Utilities

Plinth.HttpApiClient.Common

Shared objects for HTTP Api Client frameworks

Plinth.HttpApiClient

HTTP Api Client framework built on MS HttpClient

Plinth.AspNetCore

Plinth ASP.NET Core Services Utilities

GitHub repositories

This package is not used by any popular GitHub repositories.

net10.0 support