<commit_before># Brickweave.Cqrs

Brickweave CQRS is a lightweight framework library to support the CQRS pattern within a single application. Consuming applications would define commands, queries and their handlers to wrap business logic into a nice little unit of work. This not only helps teams distribute work more easily, but also helps them predict where business logic should be placed without a lot of debate.

*Warning*: This library is still under active development. The IServiceCollection integrations may change in the future.

# Getting Started

The following examples are also located in the `Brickweave.Samples` projects in this repository. These examples are simple, but often application commands and queries will require manipulation of multiple domain models, publish domain messages, or perform some aggregation of data to produce results. That being said, these samples should be sufficient to get started.

## Step 1: Wire-Up

To have your application start recognizing newly defined commands and queries, use the `IServiceCollection` extension methods to wire-up the Brickweave services. Since these services rely on dependency injection via .NET Core's `IServiceCollection`, you will want to wire-up your own domain services as well. Not that assemblies containing your command and queries can be passed to these extension methods and an assembly scan for `IQueryHandler` and `ICommandHandler` services will be executed.

This example is for ASP.NET Core, but for console or other applications a new `ServiceCollection` instance can be created and utilized as well.

### Example Wire-Up (ASP.NET Core):

``` csharp
public void ConfigureServices(IServiceCollection services)
{
    services.AddMvc();

    // find libraries that will contain my command and query handlers
    var domainAssemblies = AppDomain.CurrentDomain.GetAssemblies()
        .Where(a => a.FullName.StartsWith("MyApplication")) // your namespace prefix
        .Where(a => a.FullName.Contains("Domain")) // any additional criteria to isolate your domain libraries
        .ToArray();

    services.AddCqrs(domainAssemblies);

        ...
}

```

## Step 2: Define Command and Query

Now that your application is setup, you can add commands and queries to your domain libraries and their handlers will be automatically picked up without any additional DI container registrations (except for your additional domain services).

Lets start by defining a command and a query.

### Example Command:<commit_msg>cqrs readme formatting fix<commit_after># Brickweave.Cqrs

Brickweave CQRS is a lightweight framework library to support the CQRS pattern within a single application. Consuming applications would define commands, queries and their handlers to wrap business logic into a nice little unit of work. This not only helps teams distribute work more easily, but also helps them predict where business logic should be placed without a lot of debate.

*Warning*: This library is still under active development. The IServiceCollection integrations may change in the future.

# Getting Started

The following examples are also located in the `Brickweave.Samples` projects in this repository. These examples are simple, but often application commands and queries will require manipulation of multiple domain models, publish domain messages, or perform some aggregation of data to produce results. That being said, these samples should be sufficient to get started.

## Step 1: Wire-Up

To have your application start recognizing newly defined commands and queries, use the `IServiceCollection` extension methods to wire-up the Brickweave services. Since these services rely on dependency injection via .NET Core's `IServiceCollection`, you will want to wire-up your own domain services as well. Not that assemblies containing your command and queries can be passed to these extension methods and an assembly scan for `IQueryHandler` and `ICommandHandler` services will be executed.

This example is for ASP.NET Core, but for console or other applications a new `ServiceCollection` instance can be created and utilized as well.

### Example Wire-Up (ASP.NET Core):

``` csharp
public void ConfigureServices(IServiceCollection services)
{
    services.AddMvc();

    // find libraries that will contain my command and query handlers
    var domainAssemblies = AppDomain.CurrentDomain.GetAssemblies()
        .Where(a => a.FullName.StartsWith("MyApplication")) // your namespace prefix
        .Where(a => a.FullName.Contains("Domain")) // any additional criteria to isolate your domain libraries
        .ToArray();

    services.AddCqrs(domainAssemblies);

    ...
}

```

## Step 2: Define Command and Query

Now that your application is setup, you can add commands and queries to your domain libraries and their handlers will be automatically picked up without any additional DI container registrations (except for your additional domain services).

Lets start by defining a command and a query.

### Example Command:
{'fraction_non_alphanumeric': 0.05196881870877473, 'fraction_numerical': 0.0007995202878273036, 'mean_word_length': 4.609865470852018, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6061328', 'n_tokens_mistral': 1155, 'n_tokens_neox': 1116, 'n_words': 648}