Skip to content

Merging Commands Events

haf edited this page Jul 22, 2011 · 2 revisions

Merging Commands/Events

This section mostly revolves around the IDetectConflicts interface:

public interface IDetectConflicts
{
	void Register<TUncommitted, TCommitted>(ConflictDelegate handler)
		where TUncommitted : class
		where TCommitted : class;

	bool ConflictsWith(IEnumerable<object> uncommittedEvents, IEnumerable<object> committedEvents);
}

public delegate bool ConflictDelegate(object uncommitted, object committed);

The interface has the above public signature, where the Register method allows the command-handler-wire-up infrastructure components to register the conflict detectors. The conflict detectors that are registered are called in sequence for each stream of uncommitted events, to see whether the uncommitted (new) events conflict with events committed since the command's aggregate root version was set (i.e. what version of the AR was the decision made on).

Clone this wiki locally