Skip to content

Instantly share code, notes, and snippets.

Avatar

Derek Comartin dcomartin

View GitHub Profile
View Policy.cs
public class PlaceOrderHandler : RequestHandler<PlaceOrder>
{
private readonly IAmACommandProcessor _commandProcessor;
public PlaceOrderHandler(IAmACommandProcessor commandProcessor)
{
_commandProcessor = commandProcessor;
}
[UsePolicy(CommandProcessor.RETRYPOLICY, 3)]
View Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddSales();
services.AddShipping();
services
.AddLogging(builder =>
{
View outOfProcess.cs
public class OrdersController : Controller
{
private readonly IAmACommandProcessor _commandProcessor;
public OrdersController(IAmACommandProcessor commandProcessor)
{
_commandProcessor = commandProcessor;
}
[HttpPost("/sales/orders/{orderId:Guid}")]
View inProcess.cs
public class OrdersController : Controller
{
private readonly IAmACommandProcessor _commandProcessor;
public OrdersController(IAmACommandProcessor commandProcessor)
{
_commandProcessor = commandProcessor;
}
[HttpPost("/sales/orders/{orderId:Guid}")]
View behavior.cs
public class DemoBehavior : IPipelineBehavior<PlaceOrder, Unit>
{
private readonly ILogger<DemoBehavior> _logger;
public DemoBehavior(ILogger<DemoBehavior> logger)
{
_logger = logger;
}
public async Task<Unit> Handle(PlaceOrder request, CancellationToken cancellationToken, RequestHandlerDelegate<Unit> next)
View controller.cs
using System;
using System.Security.Claims;
using System.Threading;
using System.Threading.Tasks;
using DotNetCore.CAP;
using MediatR;
using MediatR.Pipeline;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
View OrderPlaced.cs
namespace Sales.Contracts
{
public class OrderPlaced
{
public Guid OrderId { get; set; }
public Address ShippingAddress { get; set; }
}
public class Address
{
View OrderPlaced.cs
namespace Sales.Contracts
{
public class OrderPlaced
{
public Guid OrderId { get; set; }
}
}
View unity.cs
using Unity;
using Unity.Lifetime;
namespace UnityFactory
{
class Program
{
static void Main(string[] args)
{
var container = new UnityContainer();
View program.cs
class Program
{
static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
private static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureServices((context, collection) =>
You can’t perform that action at this time.