IDDD_Samples_NET
IDDD_Samples_NET copied to clipboard
EventSourcedAggregateRoot dynamic apply
void When(IDomainEvent e)
{
(this as dynamic).Apply(e);
}
protected void Apply(IDomainEvent e)
{
this.mutatingEvents.Add(e);
When(e);
}
This code doesn't work, it generates an StackOverflow exception due to it's infinite recursion.
Ahh yes, this is the proper implementation - http://blogs.msdn.com/b/davidebb/archive/2010/01/18/use-c-4-0-dynamic-to-drastically-simplify-your-private-reflection-code.aspx
As seen here - https://github.com/gregoryyoung/m-r/blob/master/SimpleCQRS/InfrastructureCrap.DontBotherReadingItsNotImportant.cs