Bifrost icon indicating copy to clipboard operation
Bifrost copied to clipboard

When getting aggregate roots - it should allow for ConceptAs<> that are compatible for conversion to EventSourceId for the constructor

Open einari opened this issue 7 years ago • 0 comments

It increases readability and looks generally much better if we can allow having the actual domain concept as the constructor parameter for AggregateRoots / EventSources:

public class Messaging : AggregateRoot
{
    public Messaging(Inbox inbox) : base((Guid)inbox) // Conversion to Guid - as we have implicit conversion to EventSourceId from Guid
    {
    }
}

Consider also if it makes sense to have a generic AggregateRoot:

public class Messaging : AggregateRoot<Inbox>
{
    public Messaging(Inbox inbox) : base(inbox) 
    {
    }
}

This would also make it easier for the next step; applying events:

public class Messaging : AggregateRoot<Inbox>
{
    public Messaging(Inbox inbox) : base(inbox) 
    {
    }

    public void Receive(....)
    {
         Apply(new MessageReceived(eventSourceId) {....});
    }
}

with an event:

public class MessageReceived : Event
{
    public MessageReceived(Inbox inbox) : base((Guid)inbox) // Similar casting - or use generic here as well
    {
    }
}

einari avatar Apr 24 '17 20:04 einari