Skip to content

Instantly share code, notes, and snippets.

View jbogard's full-sized avatar

Jimmy Bogard jbogard

View GitHub Profile
public class MediatorPipeline<TRequest, TResponse>
: IRequestHandler<TRequest, TResponse>
where TRequest : IRequest<TResponse>
{
private readonly IRequestHandler<TRequest, TResponse> _inner;
private readonly IEnumearble<IMessageValidator<TRequest>> _validators;
private readonly IMessageAuthorizer _authorizer;
private readonly IEnumerable<IPreRequestProcessor<TRequest>> _preProcessors;
private readonly IEnumerable<IPostRequestProcessor<TRequest, TResponse>> _postProcessors;
private readonly IEnumerable<IResponseProcessor<TResponse>> _responseProcessors;

Normal property

public class Person
{
    public string LastName { get; set; }
    public string MiddleName { get; set; }
    public string FirstName { get; set; }
}
public class ಠ_ಠAttribute : Attribute
{
}
[ಠ_ಠ]
public class Manager
{
// 1000s of lines here
}
Request Handler....................................................Y
-Void Request Handler...............................................N
+Void Request Handler...............................................Y
Pipeline Behavior..................................................Y
Pre-Processor......................................................Y
Post-Processor.....................................................Y
-Constrained Post-Processor.........................................N
+Constrained Post-Processor.........................................Y
Ordered Behaviors..................................................Y
private static IEnumerable<DateTime> AllMondaysInJune2020 { get {
yield return new DateTime(2020, 6, 1);
yield return new DateTime(2020, 6, 8);
yield return new DateTime(2020, 6, 15);
yield return new DateTime(2020, 6, 22);
yield return new DateTime(2020, 6, 29);
}
}
public interface IValidator<in T> {
}
public class CompositeValidator<T> : IValidator<T> {
public CompositeValidator(params IValidator<T>[] validators) {
}
}
public interface IDomainEventDispatcher
{
void Dispatch(IDomainEvent domainEvent);
}
public class DomainEventDispatcher : IDomainEventDispatcher
{
private readonly IContainer _container;
public DomainEventDispatcher(IContainer container)
private static readonly Expression<Action<IField>> IFieldApplyMethod =
f => f.Apply(default, default);
private static readonly MethodInfo IFieldApplyMethodInf =
((MethodCallExpression)IFieldApplyMethod.Body).Method
GET /invoices
200 OK
{
[
{
"@id": "/invoices/123",
"status": 0,
"total": 199.99,
"actions": [
{ "approve": "/invoices/123/approve" }
public interface IDocumentRepository<T> where T : IAggregate {
// we expose IMongoQueryable directly because it has Mongo-specific methods
IMongoQueryable<T> Query();
Task<T> Get(Guid id);
Task Save(T document);
Task Update(T document, Expression<Func<T, bool>> filter);
Task Update(T document);
IMongoCollection<T> Collection { get; }
}