SharpAppSettings 1.0.1

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

// Install SharpAppSettings as a Cake Tool
#tool nuget:?package=SharpAppSettings&version=1.0.1

SharpAppSettings

Often times you need a quick and easy way to inject settings into the DI container. This is fairly easy with the default service collection but requires some code to get started. This project aims to make injecting settings as easy as adding an attribute and registering with the DI container.

Getting started:

  1. Create your setting classes and mark them with the AppSettingAttribute
[AppSetting("BindToMe")]
public class TestSettings
{
    public string StringValue { get; set; }
    public int NumberValue { get; set; }
    public bool BooleanValue { get; set; }
    public int[] ArrayOfNumbersValue { get; set; }
    public string[] ArrayOfStringsValue { get; set; }

    ... More public properties ...
}
  1. Update you appsettings.json file with sections you've created classes for
{
  "BindToMe": {
    "StringValue": "value",
    "NumberValue": 1,
    "BooleanValue": false,
    "ArrayOfNumbersValue": [ 0, 1, 2, 3 ],
    "ArrayOfStringsValue": [ "a", "b", "c" ]
  }
}
  1. Inside of Startup.cs register these settings by calling AddTypedSettings
serviceCollection.AddTypedSettings(configuration, typeof(ServiceCollectionExtensionsTests).Assembly);
  1. Start using those options from your DI container
public class MyService
{
    private readonly TestSettings _testSettings;

    public MyService(IOptions<TestSettings> testSettings)
    {
        _testSettings = testSettings.Value;
    }
}
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 netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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.0.1 551 12/6/2020
1.0.0 408 12/6/2020