EventSourcedAggregateRoot dynamic apply
leonfs opened this issue · 1 comments
leonfs commented
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.
eulerfx commented
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