Wlvyr.Common 0.3.0

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

Wlvyr.Common

Wlvyr.Common is a library created to aid in common project setup.

Dependency Injection

To help facilitate in loading dependency injection (DI) service across different projects, Wlvyr.Common.Interface.Configuration.IDIConfig<TContainer, TSettings> provides an interface in configuring your DI in all required projects. Then, binding and initializing the DI configurations from Wlvyr.Common.Configuration.DIBootstrap<TContainer, TAppSettings>.

An example in initializing DIBootstrap with SimpleInjector:


using SimpleInjector;

using Wlvyr.Common.Configuration;
using Wlvyr.Common.Reflection;

namespace MainProject;

public static void Main(){

    // Example to get configuration.
    var builder = WebApplication.CreateBuilder(args);
    // Access IConfiguration
    IConfiguration configuration = builder.Configuration; // or new ConfigurationBuilder().AddJsonFile("appsettings.json") .Build()

    IEnumerable<Assembly> assemblies = AssemblyHelper.GetAssemblies(
                                            nameIncludes: new HashSet<string>(){ 
                                                    "asssembly.only-included-project.name1", 
                                                    "assembly.only-included-project.name2" 
                                            }
                                        );

    var diConfig = new  DIBootstrapConfiguration<AppSettings>(
        new AppSettings(configuration),
        new HashSet<string> { "Some.Namespace.ExcludedDIConfig" } // excluded IDIconfig from being configured. empty for all to be included
    );

    var diBootstrap = new DIBootstrap(
        diConfig,
        () => new SimpleInjector.Container(), 
        () => assemblies.CreateDIConfigs<Container, TAppSettings>(diConfig.ExcludedDIConfigFullNames) // from DIExtensions.CreateDIConfigs<Container, AppSettings>
    );

    diBootstrap.Initialize();

    // d.DIContainer can now be used. example next step: Verify the DI container of your choice that it did bootstrap properly. (DIContainer.Verify is from SimpleInjector)
    d.DIContainer.Verify();   
}

Then, in a project that may not require Wlvyr.Common but only its interface, Wlvyr.Common.Interface, an implementation of IDIConfig will look like this:


using SimpleInjector;

using Wlvyr.Common.Interface.Configuration;

namespace SomeProject;

public class SomeDIConfig : IDIConfig<Container, SomeAppSetting> {

    public void Configure(Container container, SomeAppSetting configuration){
        container.Register<ILogger, FileLogger>();
    }
}

Mapper

Allow projects to define their own mapping configuration. The project doesn't require AutoMapper to be used, but is based on it. To setup, get all Wlvyr.Common.Interface.Configuration.IMapperConfig<TConfigurer> implementations, from relevant workspace projects, and then initialize.

Example usage:


using AutoMapper;
using Wlvyr.Common.Configuration;
using Wlvyr.Common.Reflection;

namespace MainProject;

public static void Main()
{
    IEnumerable<Assembly> assemblies = AssemblyHelper.GetAssemblies(
                        new HashSet<string>(){ "asssembly.project.name1", "assembly.project.name2" }
                 );

    Func<MapperConfigurationExpression> cfgExpFactory = () => MapperConfigurationExpression();
    Func<MapperConfigurationExpression, IMapper> mapperFactory = (cfg) => new MapperConfiguration(cfg).CreateMapper();   
    Func<IEnumerable<IMapperConfig<MapperConfigurationExpression>>> mapperConfigsFactory = () => assemblies.CreateMapperConfigs<MapperConfigurationExpression>(/*optionAppSettings*/); // from MappingExtensions

    var b = new MapperBootstrap<IMapper, MapperConfigurationExpression>(
        cfgExpFactory, 
        mapperFactory,
        mapperConfigsFactory,
    );

    b.Initialize();

    // b.Mapper; can now be accessed. b.Mapper will throw an error if it has not been initialized.
    // b.Mapper can be registered to a DI container. e.g. diBootstrap.DIContainer.RegisterInstance(b.Mapper);
}

Then, in a project that may not require Wlvyr.Common but only its interface, Wlvyr.Common.Interface, an implementation of IMapperConfig will look like this:


using SimpleInjector;

using Wlvyr.Common.Interface.Configuration;

namespace SomeProject;

public class SomeMapperConfig : IMapperConfig<MapperConfigurationExpression> {

    public void Configure(MapperConfigurationExpression cfg){
        cfg.CreateMap<Employee, EmployeeDTO>();
    }
}

// If appSettings is not included in assemblies.CreateMapperConfigs<MapperConfigurationExpression>(), this will not be included.
public class SomeMapperConfigWithAppSettingParam : IMapperConfig<MapperConfigurationExpression> {

    public SomeMapperConfigWithAppSettingParam(AppSettings appSettings){
        this.AppSettings = appSettings;

    }
    
    protected AppSettings AppSettings { get; init; } 

    public void Configure(MapperConfigurationExpression cfg){
        cfg.CreateMap<Employee, EmployeeDTO>();
    }
}

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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 (1)

Showing the top 1 NuGet packages that depend on Wlvyr.Common:

Package Downloads
Wlvyr.Common.DI.SimpleInjector

A helper library that simplifies common setup patterns and configurations for the SimpleInjector dependency injection container.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.3.0 151 7/9/2026
0.2.4 166 1/1/2026

- **0.3.0**: Result/Result<T> breaking changes
       - Replaced success flag with ResultStatus; removed parameterless/bool constructors
     - **0.2.4**: Updated project metadata
     - **0.2.3**: Mapper
       - MappingExtensions.CreateMapperConfigs now allows IAppSettings to be included
       - IMapperConfig implementation either have parameterless constructor or constructor with IAppSettings as parameter.