assistant.net.core 0.5.182

dotnet add package assistant.net.core --version 0.5.182
NuGet\Install-Package assistant.net.core -Version 0.5.182
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="assistant.net.core" Version="0.5.182" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add assistant.net.core --version 0.5.182
#r "nuget: assistant.net.core, 0.5.182"
#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.
// Install assistant.net.core as a Cake Addin
#addin nuget:?package=assistant.net.core&version=0.5.182

// Install assistant.net.core as a Cake Tool
#tool nuget:?package=assistant.net.core&version=0.5.182

assistant.net.core

Abstractions, basic implementations, useful tools and extensions which are commonly used across the solution.

System clock

using var provider = new ServiceCollection().AddSystemClock().BuildServiceProvider();

var now = provider.GetRequiredService<ISystemClock>().UtcNow;

System lifetime

The feature exposes access to running application lifetime to have more flexible access over application shutting down process.

It's cloned from the same purpose implementation used for .net hosted services although without respective dependencies so that it can be used in .net standard or SDK packages with the same purpose.

using var provider = new ServiceCollection().AddSystemLifetime().BuildServiceProvider();

var stoppingCancellationToken = provider.GetRequiredService<ISystemLifetime>().Stopping;

Type encoder

A tool that converts type to string and resolves it back if it's available in current application domain.

Alternative to .net default full assembly name although it ignores type assembly name/version and namespace.

using var provider = new ServiceCollection()
    .AddTypeEncoder(o => o.Exclude("NUnit").Exclude<DateTime>())
    .BuildServiceProvider();

var encoder = provider.GetRequiredService<ITypeEncoder>();

var typeName = encoder.Encode(typeof(SomeType));
var type = encoder.Decode(typeName);

Unions

Option<int> some = Option.Some(123);
Option<int> none = Option.None;

Named options

Scoped based named options configured to have specific option name within current service provider scope. It's widely used in named packages like serialization, storage, messaging.

Initializing scope with predefined name:

using var provider = new ServiceCollection()
    .AddNamedOptionsContext()
    .Configure<SomeOptions>("name", o => o.Value = 123)
    .BuildServiceProvider();
using var scope = provider.CreateScopeWithNamedOptionContext("name");

var options = scope.ServiceProvider.GetRequiredService<INamedOptions<SomeOptions>>().Value;

Override the name within existing scope:

using var provider = new ServiceCollection()
    .AddNamedOptionsContext()
    .Configure<SomeOptions>("name", o => o.Value = 123)
    .BuildServiceProvider();
using var scope = provider.CreateScope();
scope.ConfigureNamedOptionContext("name");

var options = scope.ServiceProvider.GetRequiredService<INamedOptions<SomeOptions>>().Value;

Configure options source

The .net options feature extension that gives an opportunity to reload specific options configuration including own configuration by some custom logic. E.g. options is dynamically populated during runtime.

This is an alternative solution to 'IConfigurationProvider' feature although it can be part of existing DI and it configures directly the options object instead of indirect IConfigurationRoot.

var source = new CustomConfigureOptionsSource();
using var provider = new ServiceCollection()
    .AddSingleton(source)
    .Configure<SomeOptions>("name", o => o.Value = 123)
    .BindOptions("name", source)
    .BuildServiceProvider();

var monitor = provider.GetRequiredService<IOptionsSnapshot<SomeOptions>>();
var source2 = provider.GetRequiredService<CustomConfigureOptionsSource>();

source2.Reload(o => o.Value = 321);

var options = monitor.Get<SomeOptions>("name");

internal class CustomConfigureOptionsSource : IConfigureOptionsSource { ... }

Configure options with validation

Just override of original Microsoft.Extensions.DependencyInjection.OptionsServiceCollectionExtensions extension methods with enabled data annotation validation.

using Assistant.Net;

using var provider = new ServiceCollection()
    .Configure<SomeOptions>(delegate { })
    .BuildServiceProvider();

Hash code

Simple extension methods for generating SHA1 hash code.

string byteCode = new byte[0].GetSha1();
string stringCode = "".GetSha1();
string structCode = 123.GetSha1();
string objectCode = new SomeObject().GetSha1();

Provider configuration extensions

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (7)

Showing the top 5 NuGet packages that depend on assistant.net.core:

Package Downloads
assistant.net.diagnostics

Common diagnostic services.

assistant.net.storage

A common storage abstraction, tools and its basic local (in-memory) implementation.

assistant.net.messaging

Local (in-memory) message handling implementation.

assistant.net.mongo

A MongoDB basics and configuration.

assistant.net.sqlite

An SQLite basics and configuration.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.5.182 815 5/8/2023
0.4.151 834 3/28/2023
0.4.145 1,029 3/22/2023
0.4.144 3,043 9/4/2022
0.4.140 2,919 8/13/2022
0.3.139 2,889 8/9/2022
0.3.138 2,932 8/7/2022
0.3.137 2,892 8/6/2022
0.3.135 2,780 7/14/2022
0.3.133 2,804 7/4/2022
0.3.127 2,831 6/26/2022
0.3.125 2,852 6/25/2022
0.3.123 2,804 6/23/2022
0.3.121 2,814 6/22/2022
0.3.119 2,768 6/20/2022