Skip to content

Instantly share code, notes, and snippets.

@NeilRobbins
Created May 29, 2010 17:11
Show Gist options
  • Select an option

  • Save NeilRobbins/418382 to your computer and use it in GitHub Desktop.

Select an option

Save NeilRobbins/418382 to your computer and use it in GitHub Desktop.
public interface IHandleCommands<TCommand> where TCommand : IAmACommand
{
void Handle(TCommand command);
}
public interface IAmACommand
{
Guid AggregateId { get; }
}
public class AddLineToInvoiceCommandHandler : IHandleCommands<AddLineToInvoiceCommand>
{
public void Handle(AddLineToInvoiceCommand command)
{
// ... Do Something here to handle the command, for anything else
// E.g. transactions, logging, etc... use the decorator pattern
}
}
public class AddLineToInvoiceCommand
{
Guid _aggregateId;
long _quantity;
Guid _itemId;
public AddLineToInvoiceCommand(Guid invoiceAggregateId, long quantity, Guid itemId)
{
_aggregateId = invoiceAggregateId;
_quantity = quantity;
_itemId = itemId;
}
public Guid AggregateId
{ get { return _aggregateId; } }
public long Quantity
{ get { return _quantity; } }
public Guid ItemId
{ get { return _itemId; } }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment