Skip to content

Instantly share code, notes, and snippets.

@sstorie
Created January 20, 2015 21:11
Show Gist options
  • Save sstorie/0c48a7fcea769e37c281 to your computer and use it in GitHub Desktop.
Save sstorie/0c48a7fcea769e37c281 to your computer and use it in GitHub Desktop.
Registry code
public class DefaultRegistry : Registry {
#region Constructors and Destructors
public DefaultRegistry() {
Scan(
scan => {
scan.TheCallingAssembly();
// Ensure the assembly with our IMediator interface is loaded
//
scan.AssemblyContainingType<IMediator>();
// Pull in all implementations of the request and notifications handlers
// automatically
//
scan.AddAllTypesOf(typeof(IRequestHandler<,>));
scan.AddAllTypesOf(typeof(INotificationHandler<>));
scan.AddAllTypesOf(typeof(IPreRequestHandler<>));
scan.AddAllTypesOf(typeof(IPostRequestHandler<,>));
scan.WithDefaultConventions();
});
//For<IExample>().Use<Example>();
// Setup the classes for our mediators (not needed due to convention)
//
//For<IMediator>().Use<Mediator>();
// Add our mediator pipeline as a decorator for all mediator requests
//
For(typeof(IRequestHandler<,>)).DecorateAllWith(typeof(MediatorPipeline<,>));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment