Skip to content

darrencauthon/AppBus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AppBus is a small application bus that I borrowed from MvcContrib's Portable Areas. I liked the idea of a simple, syncronous bus for decoupling, I took the ideas and wrote my own implementation.

The main difference between MvcContrib and this is that I filter the handlers according to type. In other words, message handlers can handle only one type of message, and only the handlers that can handle a specific message are instantiated when a message is passed to the bus.

public class SomethingHappened : IEventMessage {}

public class DoSomethingWhenSomethingHappens : IMessageHandler<SomethingHappened>{
	public void Handle(SomethingHappened message){
		// do something
	}
}

public class DoSomethingElseWhenSomethingHappens : IMessageHandler<SomethingHappened>{
	public void Handle(SomethingHappened message){
		// do something else
	}
}


applicationBus.Add(typeof (DoSomethingWhenSomethingHappens));
applicationBus.Add(typeof (DoSomethingElseWhenSomethingHappens));

// this message will be passed to both handlers
applicationBus.Send(new SomethingHappened());

About

Application bus, heavily inspired by MvcContrib but TDD'd up myself

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published