CMS.StdLib.Configuration 1.0.4

There is a newer version of this package available.
See the version list below for details.

Requires NuGet 2.12 or higher.

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

// Install CMS.StdLib.Configuration as a Cake Tool
#tool nuget:?package=CMS.StdLib.Configuration&version=1.0.4

CMS.StdLib.Configuration is discontinued. Version 1.0.2 will be last component released.

CMS.StdLib.Configuration

A library that provides services that make it easy to send email and sms's, store application settings, abstracts aways directory location on the filesyste and provides for exception logging

Table of contents

  1. Installation
  2. Todo
  3. Features Requests
  4. Branches
  5. Components
  6. Features

Features

  1. Provides a service to send email.
  2. Provides a service that enables a application to store its application settings in MSSQL.

Installation

Install via CMS Nuget Service

Install-Package CMS.Core.Util.Service

To Install a specific version

Install-Package CMS.Core.Util.Service -Version <latest version numer>

Todo

  • Currently the connection string is hard coded in the in EmailService class. Need to move the connection string to external store and provide an abstraction that will allow the connection string to be passed in.
  • The CMS.Core.Util.ConfigurationManagerService needs to be refactored to reduce the amount of technical debt.
  • The hard coding of the connection string in CMS.Core.Util.ConfigurationManagerService will need to be changed.

Features Requests

  • Add feature to send sms's.
  • Add feature to send a comma delimited list.
  • Add feature to add attachmnents to the email being sent.
  • Add feature that will enable customize of the Email Service to send emails using a different profile.
  • Add feature that will enable Email Service to support more parameters. See EmailServiceFeature pull request
  • Add browsable documentation for the each service.

Branches

CMS.Core.Util.Services has two branches, master and dev. Code changes are done on the dev branch and then merged into the master branch

The master branch has build policy that is triggered when there are any changes on the branch. The change will build code in the master branch and create and publish a nuget package in the CMS Nuget repository.


CMS.Core.Util.EmailService

Usage

CMS.Core.Util.EmailService Usage

The EmailService class implements a IDispose interface. So you can wrap it in a using statement, like this

using (var EmailServiceInstance = new EmailService())
{
    EmailServiceInstance.SendEmail(
      to: this._emailAddress,
      subject: "Test",
      message: "Testing");
}


CMS.Core.Util.Services.ConfigurationManagerService

The ConfigurationManagerService is a singleton. The component uses a fluent api to add, update and delete application settings.

How does it work?

The use the ConfigurationManagerService you need to add the application name, then the environments (dev, test, uat, production, etc.) the application will operate in and then the application settings for each environment.

Please note, the following:

  • The application name must be unique
  • The environment name for each application name must be unique
  • The application setting key linked to a value must be unique
  • Application settings deletions uses cascading delete. If Application info entry is deleted, then environment and application settings entries are deleted as well. If environment entry is deleted, its associated application settings are deleted as well, but the application info entry will still be present in the data store.

Usage

To add application settings for an application and for all application environments, do the following:

var environments = new List<string>();
environments.Add("Testing");
environments.Add("Staging");
environments.Add("Production");

var applicationName = $"Application Name";

ConfigurationManagerService.Instance
    .ForApplication(applicationName)
    .ForEachEnvironment(environments)
    .AddApplicationSettings("Test1","Value1")
    .Save();

To add a list of application settings for an application and for all application environments, do the following:

var environments = new List<string>();
environments.Add("Testing");
environments.Add("Staging");
environments.Add("Production");

var appSettings = new  Dictionary<string, string>();

for (int i = 1; i <= 1000; i++)
{
    appSettings.Add(key: $"Key{i}", value: $"Value{i}");
}

var applicationName = $"Application Name";

var applicationConfigExpectation = ConfigurationManagerService.Instance
    .ForApplication(applicationName)
    .ForEachEnvironment(environments)
    .AddApplicationSettings(appSettings)
    .Save();

To update application name and a specific environment name, do the following:

ConfigurationManagerService.Instance
    .ForApplication("Application Name")
    .ForEnvironment("Staging")
    .UpdateEnvironmentTo("Staging2")
    .Save();

To update application settings value with a key value of "Test1" for a specific application name and a environment name, to the following:


ConfigurationManagerService.Instance
    .ForApplication("Application Name")
    .ForEnvironment("Production")
    .ForApplicationSettingKey("Test1")
    .UpdateValueTo( "New-Value2") // will update "Value" to "New-Value2"
    .Save();

To delete an application settings with a key value of "Test1", for a specific application name and a environment name, to the following:


ConfigurationManagerService.Instance
    .ForApplication("Application Name")
    .ForEnvironment("Production")
    .ForApplicationSettings()
    .DeleteByKey("Test1")
    .Save();

To delete a environment "Production" for a specific application with the name "Application Name", do the following:


ConfigurationManagerService.Instance
    .ForApplication("Application Name")
    .ForEnvironment("Production")
    .DeleteEnvironment()
    .Save();

To delete an application with the name "Application Name", do the following:


ConfigurationManagerService.Instance
    .DeleteApplicationInfo("Application Name")
    .Save();

To get an application setting with a key value of "Test1", for a specific application name and a environment name, do the following:


var applicationSettingValue = ConfigurationManagerService.Instance
   .ForApplication("Application Name")
   .ForEnvironment("Production")
   .ForApplicationSettings()
   .GetValueByKey("Test1");

To fresh application settings before retrieving their value contents, do the following:


var result = ConfigurationManagerService.Instance
   .ForApplication("Application Name")
   .ForEnvironment("Production")
   .ForApplicationSettings()
   .RefreshApplicationSettings()
   .GetValueByKey("Test1");

To add application settings for different environments, for a specified application, do the following:


ConfigurationManagerService.Instance
   .ForApplication("Application Name")
   .ForEnvironment("UAT")
   .AddApplicationSettings("DbConnString", "Uat Db Conn String")
   .Save();

ConfigurationManagerService.Instance
   .ForApplication("Application Name")
   .ForEnvironment("Production")
   .AddApplicationSettings("DbConnString, "Production Db Conn String")
   .Save();

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 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  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 (2)

Showing the top 2 NuGet packages that depend on CMS.StdLib.Configuration:

Package Downloads
CMS.StdLib.Notification

CMS.StdLib.Notification contains features that enables you to send an email and sms using CMS infrastructure.

CMS.StdLib.Logging

CMS.StdLib.Logging provides a logging feature for CMS applications. The library uses Serilog and Serilog elastric search sink to log application data to elastic search.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.7 95 5/13/2024
1.0.6 107 5/9/2024
1.0.5 125 5/9/2024
1.0.4 318 11/14/2023
1.0.3 152 9/7/2023
1.0.0 106 11/14/2023
0.0.0 117 9/7/2023