CCG.CQRS.WebApi 1.0.8

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

// Install CCG.CQRS.WebApi as a Cake Tool
#tool nuget:?package=CCG.CQRS.WebApi&version=1.0.8

CCG.CQRS.WebApi


Add to WebApiConfig.cs:

config.Services.Replace(typeof(System.Web.Http.Filters.IFilterProvider), new OrderedFilterProvider());
config.Filters.Add(new FluentValidationActionFilter());
config.Filters.Add(new ValidateModelStateFilter());

Add to DIConfig.cs:

// CQRS Factories
container.Register<IScopedValidatorFactory, ScopedValidatorFactory>(Lifestyle.Singleton);
container.Register<IFluentValidatorProvider, FluentValidatorProvider>(Lifestyle.Singleton);
container.Register<IQueryProcessor, SimpleInjectorQueryProcessor>(Lifestyle.Singleton);
container.Register<ICommandSender, SimpleInjectorCommandSender>(Lifestyle.Singleton);
            
// CQRS classes: AbstractCommandValidators, ICommandHandlers, IQueryHandler
var assemblies = AppDomain.CurrentDomain.GetAssemblies().ToList();

var validators = assemblies
    .SelectMany(e => e.GetTypes())
    .Where(e =>!e.IsAbstract &&  !e.IsInterface && e.BaseType != null && e.BaseType.IsGenericType &&
        e.BaseType.GetGenericTypeDefinition() == typeof(AbstractCommandValidator<>) &&
        !e.BaseType.GetGenericArguments()[0].IsGenericType // don't register validator class that take generic argument ie: AbstractCommandValidation<AddCodeCommand<T>>
    ).ToList();
foreach (var type in validators) container.Register(typeof(IValidator<>).MakeGenericType(type.BaseType.GetGenericArguments()[0]), type, Lifestyle.Scoped);

container.Register(typeof(ICommandHandler<>), assemblies, Lifestyle.Scoped);

var handlerWithQueryTypes = container.GetTypesToRegister(typeof(IQueryHandler<,>), assemblies, new TypesToRegisterOptions() { IncludeGenericTypeDefinitions = false, IncludeComposites = false });
container.Register(typeof(IQueryHandler<,>), handlerWithQueryTypes, Lifestyle.Scoped);

var handlerTypes = container.GetTypesToRegister(typeof(IQueryHandler<>),assemblies,new TypesToRegisterOptions(){IncludeGenericTypeDefinitions = false,IncludeComposites = false});
foreach (var type in handlerTypes) container.Register(type, type, Lifestyle.Scoped);
Product Compatible and additional computed target framework versions.
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 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
1.0.8 2,639 5/2/2018
1.0.8-r33 743 6/28/2018
1.0.7 5,000 5/2/2018
1.0.6 854 5/2/2018
1.0.5 847 5/2/2018
1.0.4 961 5/1/2018
1.0.3 962 5/1/2018
1.0.2 934 5/1/2018
1.0.1 1,002 3/14/2018
1.0.0 929 3/14/2018