Skip to content

Instantly share code, notes, and snippets.

@ashic
Created February 1, 2012 16:34

Revisions

  1. ashic created this gist Feb 1, 2012.
    37 changes: 37 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    public class SomeCommandHandler
    {
    public void Handle(SomeCommand command)
    {
    }
    }

    public class UoWWrapper
    {
    public UoWWrapper(Action<object> next)
    {
    _next = next;
    }

    public void Handle(object command)
    {
    var uow = new UoW()
    {
    _next(command);
    uow.Commit();
    }
    }
    }

    public class CompositionRoot
    {
    public void Setup()
    {
    var bus = new Bus();
    var someHandler = new SomeCommandHandler().Handle;
    var wrapped = new UoWWrapper(someHandler).Handle;
    bus.RegisterCommand<SomeCommand>(wrapped);
    }
    }


    //Some widening - narrowing may be needed between Action<T> and Action<object> but that's trivial