Skip to content

FluentMediator 0.X.X

Ivan Paulovich edited this page Oct 21, 2019 · 16 revisions

Messaging API

namespace FluentMediator
{
    public interface IMediator : Pipelines.Pipeline.IMediator,
        Pipelines.PipelineAsync.IMediator,
        Pipelines.CancellablePipelineAsync.IMediator { }
}

namespace FluentMediator.Pipelines.Pipeline
{
    public interface IMediator
    {
        void Publish(object request, string? pipelineName = null);
        TResult Send<TResult>(object request, string? pipelineName = null);
    }
}

namespace FluentMediator.Pipelines.PipelineAsync
{
    public interface IMediator
    {
        Task PublishAsync(object request, string? pipelineName = null);
        Task<TResult> SendAsync<TResult>(object request, string? pipelineName = null);
    }
}

namespace FluentMediator.Pipelines.CancellablePipelineAsync
{
    public interface IMediator
    {
        Task PublishAsync(object request, CancellationToken ct, string? pipelineName = null);
        Task<TResult> SendAsync<TResult>(object request, CancellationToken ct, string? pipelineName = null);
    }
}

Exceptions

public class ReturnFunctionIsNullException : MediatorException { }
public class PipelineNotFoundException : MediatorException { }
public class NullRequestException : MediatorException { }

Building Pipelines API

namespace FluentMediator
{
    public interface IPipelineProviderBuilder : Pipelines.Pipeline.IPipelineProviderBuilder,
        Pipelines.PipelineAsync.IPipelineProviderBuilder,
        Pipelines.CancellablePipelineAsync.IPipelineProviderBuilder
        {
            IPipelineBehavior<TRequest> On<TRequest>();
            IPipelineProvider Build();
        }

    public interface IPipelineProvider : Pipelines.Pipeline.IPipelineProvider,
        Pipelines.PipelineAsync.IPipelineProvider,
        Pipelines.CancellablePipelineAsync.IPipelineProvider { }
}
namespace FluentMediator.Pipelines
{
    public interface IPipelineBehavior<TRequest>
    {
        IPipelineBuilder<TRequest> Pipeline(string? pipelineName = null);
        IPipelineAsyncBuilder<TRequest> PipelineAsync(string? pipelineName = null);
        ICancellablePipelineAsyncBuilder<TRequest> CancellablePipelineAsync(string? pipelineName = null);
    }
}
namespace FluentMediator.Pipelines.Pipeline
{
    public interface IPipelineBuilder<TRequest> : IPipelineBuilder
    {
        IPipelineBuilder<TRequest> Call<THandler>(Action<THandler, TRequest> action);
        IPipeline Return<TResult, THandler>(Func<THandler, TRequest, TResult> func);
    }
}
namespace FluentMediator.Pipelines.CancellablePipelineAsync
{
    public interface ICancellablePipelineAsyncBuilder<TRequest> : ICancellablePipelineAsyncBuilder
    {
        ICancellablePipelineAsyncBuilder<TRequest> Call<THandler>(Func<THandler, TRequest, CancellationToken, Task> func);
        ICancellablePipelineAsync Return<TResult, THandler>(Func<THandler, TRequest, CancellationToken, Task<TResult>> func);
    }
}
namespace FluentMediator.Pipelines.PipelineAsync
{
    public interface IPipelineAsyncBuilder<TRequest> : IPipelineAsyncBuilder
    {
        IPipelineAsyncBuilder<TRequest> Call<THandler>(Func<THandler, TRequest, Task> func);
        IPipelineAsync Return<TResult, THandler>(Func<THandler, TRequest, Task<TResult>> func);
    }
}

Exceptions

public class PipelineAlreadyExistsException : MediatorException { }
Clone this wiki locally