Popularity
0.9
Growing
Activity
6.1
-
0
3
1

Programming language: C#
License: MIT License
Tags: Simpleinjector     IOC     FluentValidation    

AdaskoTheBeAsT.FluentValidation.SimpleInjector alternatives and similar packages

Based on the "IoC" category.
Alternatively, view AdaskoTheBeAsT.FluentValidation.SimpleInjector alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of AdaskoTheBeAsT.FluentValidation.SimpleInjector or a related project?

Add another 'IoC' Package

README

AdaskoTheBeAsT.FluentValidation.SimpleInjector

FluentValidation extensions to SimpleInjector

Badges

Build Status Azure DevOps tests Azure DevOps coverage Quality Gate Status Sonar Tests Sonar Test Count Sonar Test Execution Time Sonar Coverage Nuget

Usage

This library scans assemblies and adds implementations of IValidator<> to the SimpleInjector container.

There are few options to use with Container instance:

  1. Marker type from assembly which will be scanned
    container.AddFluentValidation(typeof(MyValidator), type2 /*, ...*/);
  1. List of assemblies which will be scanned.

Below is sample for scanning assemblies from some solution.

```cs
[ExcludeFromCodeCoverage]
public static class FluentValidationConfigurator
{
    private const string NamespacePrefix = "YourNamespace";

    public static void Configure(Container container)
    {
        var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies().ToList();
        var assemblies = new List<Assembly>();
        var mainAssembly = typeof(FluentValidationConfigurator).Assembly;
        var refAssemblies = mainAssembly.GetReferencedAssemblies();
        foreach (var assemblyName in refAssemblies
            .Where(a => a.FullName.StartsWith(NamespacePrefix, StringComparison.OrdinalIgnoreCase)))
            {
                var assembly = loadedAssemblies.Find(l => l.FullName == assemblyName.FullName)
                    ?? AppDomain.CurrentDomain.Load(assemblyName);
                assemblies.Add(assembly);
            }
        container.AddFluentValidation(assemblies);
    }
}

1. Special configuration action with different lifetime for validators

   ```cs
    container.AddFluentValidation(
        cfg =>
        {
            cfg.WithAssembliesToScan(assemblies);
            cfg.AsScoped();
        });