Created
January 5, 2013 10:38
-
-
Save bwatts/4460937 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WorkItem : Aggregate | |
{ | |
public WorkItem(EntityId id, string description, TimeSpan retryInterval) | |
{ | |
Announce(new WorkItemCreatedEvent(id, description, retryInterval)); | |
} | |
public string Description { get; private set; } | |
public Progress Progress { get; private set; } | |
public TimeSpan RetryInterval { get; private set; } | |
public Uri ResultLocation { get; private set; } | |
private void Handle(ReportProgressCommand command) | |
{ | |
Announce(command.Progress == Progress.Complete | |
? new ProgressReportedEvent(Id, Progress, command.ResultLocation) | |
: new ProgressReportedEvent(Id, Progress, command.Progress)); | |
} | |
private void Observe(WorkItemCreatedEvent e) | |
{ | |
OnCreated(e.WorkItemId, e.When); | |
Description = e.Description; | |
RetryInterval = e.RetryInterval; | |
Progress = Progress.Accepted; | |
} | |
private void Observe(ProgressReportedEvent e) | |
{ | |
OnModified(e.When); | |
Progress = e.NewProgress; | |
ResultLocation = e.ResultLocation; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment