Skip to content

Instantly share code, notes, and snippets.

View jbogard's full-sized avatar

Jimmy Bogard jbogard

View GitHub Profile

Normal property

public class Person
{
    public string LastName { get; set; }
    public string MiddleName { get; set; }
    public string FirstName { get; set; }
}
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);
}
}
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; }
}
public class ValidatorBehavior<TRequest, TResponse>
: IPipelineBehavior<TRequest, TResponse> where TRequest : IValidatable
{
private readonly IEnumerable<IValidator<T>> _validators;
public ValidatorBehavior(IEnumerable<IValidator<T>> validators)
=> _validators = validators
public Task<TResponse> Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate<TResponse> next)
{
Program.CreateHostBuilder()
.ConfigureServices(services => services.AddSingleton<IFooService>(fooServiceMock.Object);