No infrastructure setup is required; Scritchy finds out by itself what the commands/events/ar's
and eventhandlers are.
Eventstorage is also auto-wired; Scrichy looks for a connectionstring named "eventstore"
in the app configuration, and if it can not find it, it uses the InMemoryEventStore.
Currently works with SQLite and MsSql(CE), but other implementations should be trivial.
Develop a working CQRS app on your own in a few minutes
Here is a video of me implementing a domain from scratch:
Start a new Project.
Add Scritchy to the references using Nuget.
Implement your domain using the following conventions:
All aggregate roots must inherit from Scritchy.Domain.AR.
Commands and events are routed to an AR which contains a method void [Command.GetType().Name]
and where the Command contains a property named [AR.GetType().Name+"Id"].
Events are routed to classes that contain a method void ["On"+Event.GetType().Name].
Commands and event members are passed into the caller method by matching their property
name.
Remark: all event handlers must be stateless; sagas can be implemented as event handlers.
Configure the eventstore of your choice:
In memory persistence: do nothing.
Database persistence: add a connectionstring named "eventstore" to your
web/app.config, and make sure the database is available and the required DLL's are referenced as well (i.e. System.Data.SQLite
or System.Data.SqlServerCe for example).
Remark: installing Scritchy using NuGet automatically adds an example SQLite and
MsSqlCe database to your App_data folder. you can use these files as your database.
Create your command bus:
var bus = new ScritchyBus();
This will create a new commandbus and will auto-wire all AR's, EventHandlers, Commands.
Remark: Event handlers are instantiated trough DI, which can be set in the ScritchyBus
constructor.