I am using Glimpse.Mvc5 (1.5.3) in a MVC5 project and I am making a custom tab. This tab needs information that will be logged from inside another project.
This project is not MVC, and is referenced by my MVC project.
I've managed to get the MessageBroker
in two ways, but I don't think either of them are perfect:
IMessageBroker broker = GlimpseConfiguration.GetConfiguredMessageBroker();
I first tried this, with success, but the method is marked as deprecated, so no deal
GlimpseRuntime glimpseRuntime = HttpContext.Current.Application.Get("__GlimpseRuntime") as GlimpseRuntime;
IMessageBroker broker = glimpseRuntime.Configuration.MessageBroker;
Then I tried this, also with success, but two things bothered me: I had to add a reference to System.Web (for the HttpContext
) which is really out of place in my project.
Using "__GlimpseRuntime"
looks like something that could break in future releases.
I also realize this is breaking abstraction (a WEB tool showing up in my other project), so if a better answer doesn't use the MessageBroker
altogether it is fine by me.
For now, I'd recommend using the deprecated GlimpseConfiguration.GetConfiguredMessageBroker()
technique you've found. (If it's working for you.)
The new version of Glimpse we are working on now handles messaging from other projects and processes as a first class citizen. Just be prepared to make some changes if/when you upgrade.