Mazilious.Common 0.4.0

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

Mazilious.Common

A collection of common utilities and helpers, providing reusable components for configuration management, MongoDB integration, and HashiCorp Vault support.

Features

🔧 Configuration Extensions

  • Vault Integration: Seamlessly integrate HashiCorp Vault as a configuration source
  • Configuration Binding: Simplified configuration binding to strongly-typed options classes
  • Override Support: Support for appsettings.override.json for local development

🗄️ MongoDB Integration

  • Fluent Builder Pattern: Easy-to-use MongoDB configuration with a fluent API
  • Dependency Injection: Full support for .NET dependency injection
  • Type-Safe Collections: Register MongoDB collections with compile-time type safety

Installation

dotnet add package Mazilious.Common

Usage

Configuration with Vault

Configure your application to use HashiCorp Vault for secrets management:

using Mazilious.Common.Configuration;

var builder = WebApplication.CreateBuilder(args);

// Configure configuration sources including Vault
builder.Configuration.ConfigureConfiguration();

appsettings.json:

{
  "VaultSettings": {
    "Address": "https://vault.example.com",
    "Token": "your-vault-token",
    "MountPath": "kv",
    "SecretPath": "myapp/secrets"
  }
}

Binding Configuration to Options

Bind configuration sections to strongly-typed options classes:

using Mazilious.Common.Configuration;

// Automatically binds the section name matching the class name
services.BindFromConfiguration<MySettings>(configuration);

MongoDB Setup

Configure MongoDB with the fluent builder pattern:

using Mazilious.Common.Mongo;

var builder = WebApplication.CreateBuilder(args);

// Add MongoDB with collections
builder.Services
    .AddMongo(builder.Configuration)
    .ConfigureMongo()
    .RegisterMongoCollection<User>("users")
    .RegisterMongoCollection<Product>("products");

appsettings.json:

{
  "MongoDbSettings": {
    "ConnectionString": "mongodb://localhost:27017",
    "DatabaseName": "myapp"
  }
}

Using MongoDB in your services:

public class UserService
{
    private readonly IMongoCollection<User> _users;

    public UserService(IMongoCollection<User> users)
    {
        _users = users;
    }

    public async Task<User> GetUserAsync(string id)
    {
        return await _users.Find(u => u.Id == id).FirstOrDefaultAsync();
    }
}

Configuration Classes

VaultSettings

public class VaultSettings
{
    public string Address { get; set; }      // Vault server address
    public string Token { get; set; }        // Authentication token
    public string MountPath { get; set; }    // Mount path (default: "kv")
    public string SecretPath { get; set; }   // Path to secrets
}

MongoDbSettings

public record MongoDbSettings
{
    public string ConnectionString { get; set; }  // MongoDB connection string
    public string DatabaseName { get; set; }      // Database name
}

Requirements

  • .NET 9.0 or later

Dependencies

  • Microsoft.Extensions.Configuration
  • Microsoft.Extensions.DependencyInjection
  • MongoDB.Driver
  • VaultSharp
  • Polly

License

MIT

Repository

https://github.com/mfalicoff/mazilious.common

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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
0.4.0 603 11/30/2025
0.3.0 300 11/14/2025
0.2.0 301 11/11/2025
0.1.0 299 11/11/2025