NetModules.Settings.LocalSettings 1.3.8.4

dotnet add package NetModules.Settings.LocalSettings --version 1.3.8.4
                    
NuGet\Install-Package NetModules.Settings.LocalSettings -Version 1.3.8.4
                    
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="NetModules.Settings.LocalSettings" Version="1.3.8.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NetModules.Settings.LocalSettings" Version="1.3.8.4" />
                    
Directory.Packages.props
<PackageReference Include="NetModules.Settings.LocalSettings" />
                    
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 NetModules.Settings.LocalSettings --version 1.3.8.4
                    
#r "nuget: NetModules.Settings.LocalSettings, 1.3.8.4"
                    
#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 NetModules.Settings.LocalSettings@1.3.8.4
                    
#: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=NetModules.Settings.LocalSettings&version=1.3.8.4
                    
Install as a Cake Addin
#tool nuget:?package=NetModules.Settings.LocalSettings&version=1.3.8.4
                    
Install as a Cake Tool

NetModules.Settings.LocalSettings

NetModules.Settings.LocalSettings is a basic settings module that is built using the NetModules architecture.

It is designed to load and return configuration settings for other modules from a local file if a NetModules module raises a GetSettingEvent or uses its GetSetting(settingName, defaultValue) wrapper method. The settings are stored in a JSON file and loaded using NetTools.Serialization.Json. NetTools.Serialization.Json allows line comments in JSON so you can add descriptions and documentation, while JSON makes configuration files easy to read and modify.

A Module doesn't need to worry about how settings are provided unless it's a settings provider Module!

When added to your project, this module is attributed with AutoLoad and LoadFirst, a high LoadPriority and a lowest HandlePriority.

See NetModules.Interfaces.IModuleAttribute and NetModules.Attributes.ModuleAttribute for detailed explanation regarding module attributes.

This means that the module should be ready to serve required settings to other modules while they are loading, and if another settings provider module is loaded with a higher HandlePriority, it will override the settings provided by this module. This allows for a flexible and extensible settings architecture, where multiple modules can provide settings, and the most appropriate module will be used based on priority.

Features

  • Local Settings: Store module settings in local JSON files.
  • Event-Driven: Uses events to retrieve settings, allowing for dynamic configuration.
  • Easy Integration: Simple to integrate with existing modules.

Getting Started

Installation

To use MetModules.Settings.LocalSettings, add the library to your module hosting project via NuGet Package Manager:

Install-Package NetModules.Settings.LocalSettings

When you load modules using ModuleHost.Modules.LoadModules();, NetModules.Settings.LocalSettings will be loaded and ready to serve settings to other modules.

Quick Examples

Create a Default Settings File

If you are implementing user defined settings in your own module, and would like to add support for NetModules.Settings.LocalSettings, you should include a default settings file with your module. This file will be used to create a new settings file if one does not exist. The default settings file should be named settings.json and placed in the root of your module project.

{
  // Comments are supported to explain your default settings.
  "mySetting": "Default Value",
  "myOtherSetting": 42
}

you can request a setting from your module using the GetSetting method:

var mySetting = this.GetSetting("mySetting", "Default Value");

If you are packaging your module for distribution, you should include the settings file in your NuGet package. This will ensure that the default settings file is included when your module is installed. You can do this by adding the file to your nuspec or csproj file.

<ItemGroup>
    <None Update="ExampleModuleNamespace.ExampleModuleName.settings.default.json">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
	  <Pack>true</Pack>
	  <PackageCopyToOutput>true</PackageCopyToOutput>
    </None>
  </ItemGroup>

Overriding a Local Default Settings File

If you wish to override the default settings file with a local settings file, you can create a settings file in the root of your module host project. This file will be used to override the default settings file when the module is loaded.

E.g. ExampleModuleNamespace.ExampleModuleName.settings.json

{
  "mySetting": "Overridden Value",
  "myOtherSetting": 100
}

Handling Secure Settings

Add sensitive settings to a "secureSettings" array in your settings file:

{
  "apiKey": "Super-Secret-Key",
  "secureSettings": ["apiKey"]
}

  • Always include a default settings file to document available configurations.
  • Use secure settings for sensitive data to help restrict unauthorized access if needed.
  • Consider alternative settings storage/retrieval solutions (e.g. Remote database, secure/cloud storage, etc...).
  • For more reference on implementation, refer to the other NetModules repositories.

Contributing

We welcome contributions! To get involved:

  1. Fork NetModules.Settings.LocalSettings, make improvements, and submit a pull request.
  2. Code will be reviewed upon submission.
  3. Join discussions via the issues board.

License

NetModules.Settings.LocalSettings is licensed under the MIT License, allowing unrestricted use, modification, and distribution. If you use NetModules.Settings.LocalSettings in your own project, we’d love to hear about your experience, and possibly feature you on our website!

Full documentation coming soon!

NetModules Foundation

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  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

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.3.8.4 184 5/16/2025
1.3.8 145 5/8/2025