RapidCqrs.Autofac 1.0.1

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

// Install RapidCqrs.Autofac as a Cake Tool
#tool nuget:?package=RapidCqrs.Autofac&version=1.0.1                

RapidCQRS

This is free .NET Standard 2.0 library for Command Query Responsibilyty Segregation. You can use this library with .NET Core >= 2.0 and .NET Framework >= 4.61

Getting Started

These instructions will help you to attach this library to your project

Installing

Instalation with Nuget

Install-Package RapidCqrs

For autofac integration use RapidCqrs.Authofac

Install-Package RapidCqrs.Autofac

Usage

With autofac integration

  static void Main(string[] args)
        {
	    var containerBuilder = new ContainerBuilder();
            containerBuilder
                .AddRapidCqrs()
                .Register(typeof(MySimpleCommandHandler)) // Register manualy
                .Register<MySimpleEventHandler>() // Register manualy generic way
                .RegisterDefaultHandler<MyDefaultHandler>();
                //.RegisterDefaultHandler(typeof(MyDefaultHandler));
            //.AutoRegisterHandlers(Assembly.GetEntryAssembly()); // Register automatically

            containerBuilder
                .RegisterType<TestParam>()
                .AsSelf();

            IContainer container = containerBuilder
                .Build();

            var mediator = container.Resolve<IMediator>();

            mediator.Send(new MySimpleEvent());
            MySimpleResponse resp = mediator.Execute(new MySimpleCommand());
            mediator.Send(new MyAnotherEvent());
		}

With any another cointainer

  static void Main(string[] args)
        {
	    var containerBuilder = new ContainerBuilder();
            var cqrsBuilder = new CqrsBuilder();

            cqrsBuilder
                //.Register(typeof(MySimpleCommandHandler)) // Register manualy
                //.Register(typeof(MySimpleEventHandler));
                .AutoRegisterHandlers(Assembly.GetEntryAssembly()) // Register automatically                
                .RegisterContainer(new ContainerRegistration(x => containerBuilder.RegisterType(x).AsSelf()));

            containerBuilder
                .Register(x =>
                {
                    var scope = x.Resolve<ILifetimeScope>();
                    cqrsBuilder.RegisterResolver(new BasicHandlerResolver(scope.Resolve));
                    return cqrsBuilder.Build();
                })
                .As<IMediator>()
                .SingleInstance();

            containerBuilder
                .RegisterType<TestParam>()
                .AsSelf();

            var container = containerBuilder
                .Build();

            var mediator = container.Resolve<IMediator>();
            mediator.SendAsync(new MySimpleEvent());
            MySimpleResponse resp = mediator.Execute(new MySimpleCommand());
		}

Without any container

  static void Main(string[] args)
        {
            var cqrsBuilder = new CqrsBuilder();
            var mediator = cqrsBuilder
                //.Register(typeof(MySimpleCommandHandler)) // Register manualy
                //.Register(typeof(MySimpleEventHandler));
                .AutoRegisterHandlers(Assembly.GetEntryAssembly()) // Register automatically                
                .Build();

            // mediator.SendAsync(new MySimpleEvent()); // No parametreless constructor exception
            MySimpleResponse resp = mediator.Execute(new MySimpleCommand());
        }

Authors

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details

Need help with event sourcing?

https://msdn.microsoft.com/en-us/library/jj554200.aspx
https://docs.microsoft.com/en-us/nuget/consume-packages/ways-to-install-a-package
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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.1 1,253 4/13/2018
1.0.0 998 4/11/2018