Configuration Defaults
Overview
VersaTul.Configuration.Defaults provides prebuilt configuration builders for common VersaTul packages.
It is designed to reduce setup time by giving you sensible baseline keys and values that you can extend or override before producing a ConfigSettings instance.
When To Use This Package
Use this package when you want to:
Bootstrap a VersaTul package quickly with known configuration keys.
Keep default values in one place and override only what is environment-specific.
Build configuration dictionaries fluently in code.
Standardize configuration setup across multiple services or projects.
Installation
Install the package with the .NET CLI:
dotnet add package VersaTul.Configuration.Defaults
Or with the Package Manager Console:
PM> NuGet\Install-Package VersaTul.Configuration.Defaults -Version latest
Core Types And Concepts
ConfigurationBuilderAbstract base builder that supports fluent
AddOrReplace()calls and producesConfigSettings.ConfigurationEnvironmentEnvironment enum used to add common environment markers such as development, test, and production.
- Namespace-specific
Builderclasses Each supported package area provides its own builder with package-specific defaults.
Supported Builder Namespaces
VersaTul.Configuration.Defaults.CachingVersaTul.Configuration.Defaults.EntityFrameworkCoreVersaTul.Configuration.Defaults.LoggerVersaTul.Configuration.Defaults.MailerVersaTul.Configuration.Defaults.MongoDBVersaTul.Configuration.Defaults.MsSqlVersaTul.Configuration.Defaults.Sql
Key Builder Features
AddOrReplace(string key, object value)updates a single setting.AddOrReplace(IEnumerable<KeyValuePair<string, object>> valuePairs)updates many settings at once.AddOrReplace(IDictionary<string, object> keyValuePairs)merges an existing dictionary into the builder.AddDevelopmentPreset(),AddTestPreset(), andAddProductionPreset()add standard environment markers.BuildConfig()returns aConfigSettingsinstance.BuildSnapshot()returns a read-only view of the accumulated configuration.
Basic Example
This example starts with the MongoDB defaults and overrides the connection string.
using VersaTul.Configuration.Defaults.MongoDB;
var configSettings = new Builder()
.AddOrReplace("MongoDb", "mongodb://root:password123@127.0.0.1:27017/DemoDb")
.BuildConfig();
The MongoDB builder already includes defaults such as:
MongoDbConnectionNameSocketTimeoutConnectTimeoutMaxConnectionIdleTimeEnabledSslProtocols
Composed Example
You can combine package defaults with environment metadata and project-specific overrides.
using VersaTul.Configuration.Defaults;
using VersaTul.Configuration.Defaults.Sql;
var builder = new Builder()
.AddProductionPreset()
.AddOrReplace("DBCon", "Server=.;Database=MainDb;Trusted_Connection=True;")
.AddOrReplace("CommandTimeout", 900);
var settings = builder.BuildConfig();
var snapshot = builder.BuildSnapshot();
Typical Default Keys
Some of the most commonly used defaults include:
SQL:
CommandTimeoutandSqlDbConnectionName.MS SQL:
BulkCopyTimeout.MongoDB:
MongoDbConnectionName,SocketTimeout,ConnectTimeout, andMaxConnectionIdleTime.Mailer:
SmtpServer,SmtpPort,FromAddress,ToAddress, andMaxAttachmentSize.Logger builders: keys such as file path, file name, endpoint, or base URL depending on the logger implementation.
Notes
Start with the closest builder to your target package instead of building settings entirely by hand.
Override only the values that differ for your environment or application.
Feed the resulting
ConfigSettingsdirectly into your configuration class from Configuration.If you need to audit what a builder produced before runtime wiring, use
BuildSnapshot().