Meditatr 1.0.1

dotnet tool install --global Meditatr --version 1.0.1                
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local Meditatr --version 1.0.1                
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=Meditatr&version=1.0.1                
nuke :add-package Meditatr --version 1.0.1                

Meditatr

NuGet Badge

Meditatr is a dotnet CLI tool for scaffolding Mediator Patterns (Command and Queries and their Handlers)

Installation

To install use dotnet cli:

dotnet tool install --global Meditatr

To uninstall:

dotnet tool uninstall Meditatr --global

How to Use

Show help information:

med -h

Commands

Show help for commands:

med Command -h

Example creating command and its handler:

med Command -m Product -a Add -r long -p MyProject.Dtos -H MyProject.Handlers

as a result two classes have been created:

  • Command class named 'AddProductCommand':
using MediatR;

namespace MyProject.Dtos.Commands.ProductCommands
{
    public class AddProductCommand : IRequest<long>
    {
    }
}
  • and its handler named 'AddProductCommandHandler'
using MediatR;

using MediatR;
using MyProject.Dtos.Commands.ProductCommands;
using System.Threading;
using System.Threading.Tasks;

namespace MyProject.Handlers.Commands.ProductCommands
{
    public class AddProductCommandHandler : IRequestHandler<AddProductCommand, long>
    {
        public Task<long> Handle(AddProductCommand request, CancellationToken cancellationToken)
        {
            throw new System.NotImplementedException();
        }
    }
}

Queries

Show help for queries:

med Query -h

Example creating query and its handler:

med Query -m Product -a Get -r ProductDto -p MyProject.Dtos -H MyProject.Handlers

as a result two classes have been created:

  • Query class named 'GetProductQuery':
using MediatR;

namespace MyProject.Dtos.Queries.ProductQueries
{
    public class GetProductQuery : IRequest<ProductDto>
    {
    }
}
  • and its handler named 'GetProductQueryHandler'
using MediatR;

using MediatR;
using MyProject.Dtos.Queries.ProductQueries;
using System.Threading;
using System.Threading.Tasks;

namespace MyProject.Handlers.Queries.ProductQueries
{
    public class GetProductQueryHandler : IRequestHandler<GetProductQuery, ProductDto>
    {
        public Task<ProductDto> Handle(GetProductQuery request, CancellationToken cancellationToken)
        {
            throw new System.NotImplementedException();
        }
    }
}

Data Transfer Objects

Show help for dtos:

med Dto -h

Example creating dto:

med Dto -m Product -a -p MyProject.Dtos

NOTE: Command MUST be executed where model class located

Let's assume there is a model class with following structure'


namespace MyProject.Domain
{
    public class Product
    {
        public long Id { get; private set; }
        public string Title { get; private set; }
        public string Description { get; private set; }
        public decimal Price { get; private set; }
    }
}

after execution of the command 'ProductDto' class had been created


namespace MyProject.Dtos.Queries.ProductQueries
{
    public class ProductDto
    {
        public long Id { get; set; }
        public string Title { get; set; }
        public string Description { get; set; }
        public decimal Price { get; set; }
    }
}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
1.0.1 571 5/27/2022
1.0.0 451 5/23/2022