dotnet_common 1.2.0

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

// Install dotnet_common as a Cake Tool
#tool nuget:?package=dotnet_common&version=1.2.0

dotnet_common

Commonly used helpers for dotnet core.

Installation

This package can be installed via nuget using:

Install-Package dotnet_common

Or via the dotnet CLI using:

dotnet add package dotnet_common

Usage

For use with the built in dependency injection framework of a .net core web app / api, install the package (as per above) and then add whichever service you would like to use to your ConfigureServices method in your startup.cs class:

//cache manager class added as a singleton to keep one instance alive in your application
services.AddSingleton<dotnet_common.Interface.ICacheManager, dotnet_common.CacheManager.MemoryCache>();

//file system utility
services.AddScoped<dotnet_common.Interface.IFileSystemUtility, dotnet_common.FileSystemUtility.SystemIO>();

//marshaller that uses the data contract serializer
services.AddScoped<dotnet_common.Interface.IMarshaller, dotnet_common.Marshaller.DataContractSerializer>();

//encyption utility that uses AES
services.AddScoped<dotnet_common.Interface.IEncryptionUtility, dotnet_common.EncryptionUtility.AesEncryptionUtility>();

Next you can use whichever class you want in your controllers by adding them like so:

[Route("api/[controller]")]
public class ValuesController : Controller
{
    private readonly dotnet_common.Interface.ICacheManager _cacheManager;
    private readonly dotnet_common.Interface.IMarshaller _marshaller;
    private readonly dotnet_common.Interface.IFileSystemUtility _fileSystemUtility;
    private readonly dotnet_common.Interface.IEncryptionUtility _encryptionUtility;

    public [ControllerName]Controller(dotnet_common.Interface.ICacheManager cacheManager,
        dotnet_common.Interface.IMarshaller marshaller,
        dotnet_common.Interface.IFileSystemUtility fileSystemUtility,
        dotnet_common.Interface.IEncryptionUtility encryptionUtility)
    {
        _cacheManager = cacheManager;
        _marshaller = marshaller;
        _fileSystemUtility = fileSystemUtility;
        _encryptionUtility = encryptionUtility;
    }
}

You would then be able to use the privately instantiated version of the relevant class in your code.

Samples

There is a sample project included in the code to show usage in a dotnet core web API project.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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. 
.NET Core netcoreapp2.0 is compatible.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.2.0 1,013 7/10/2018
1.1.0 867 7/1/2018
1.0.1 890 6/30/2018
1.0.0 794 6/30/2018

Added new methods to IEncryptionUtility to hash a password and verify the password using the hash.