MessageBoxService Enhancements

Mar 13, 2012 at 12:02 PM


Early on when we started using Cinch, we noticed some limitations in the message box service, namely hardcoded captions (we sometimes need something more explicit, and the apps are bilingual too) and inability to set a specific button as the default button (e.g. having "Cancel" as the default instead of "Ok" ). I ended up adding more methods to the service to take care of that.

A few teams working on other projects have also started using Cinch and I'd like to share the enhancements with them, but one of them brought up an interesting issue that came up a while back: We use CSLA and originally the enhancements made were integrated directly into its code base, which made it very difficult to upgrade to new versions - the actual enhancements could easily be put into a separate project, while changing all the namespace names was a bad idea to begin with (let's not go there...)  So his point was: "Are we digging ourselves in the same hole by modifying the "stock" message box service with our own enhancements?"  Granted, this is not nearly as bad as what was done to CSLA (and Cinch is much smaller), but if it can be avoided...

At first I was thinking of a partial class, but that won't work since it would be in a separate project (remember, the idea is to leave the Cinch code base alone.)  That would leave a brand new message box service with a different name, since the other one is built into Cinch.  Not a big deal, if not for the fact that the code that we've written would now need to change (i.e. any reference to IMessageBoxService would need to be changed to "whatever name I pick").

I had a question coming in here... Ah, yes... :)  I was wondering if I'm just not seeing another possible alternative?  Or maybe would you consider accepting a contribution for enhancements to the IMessageBoxService built into Cinch?  (I have nothing fancy in mind - I just want to bring in the possibility of specifying the captions and some control over the buttons, pretty much in line with what WPF offers for message boxes).


Mar 13, 2012 at 7:39 PM
Edited Mar 13, 2012 at 7:42 PM


Is this for Cinch V1 or Cinch V2 (MEF based one) as I don'y really spend much time on V1 any more.

I am open to taking on contributions (though these days my time is quite limited so I can't obligate to too much), but in theory send them to me and I will have a play, and if I like them they are in.

What I like about using MEF for V2 though, is if you don't like my services just make your own, and give the export a different name/interface and there you go, you are ready to rock. In Cinch V1 it was a bit harder, as you had to adhere to my interface, but it was still possible.

Mar 14, 2012 at 12:41 PM

It's for V2.

The coffee hadn't quite kicked in yesterday, and only later did it dawn on me that changing the existing client code base to use, say "IMessageBoxServiceEx" (yeah, that's original, I know :)) instead of "IMessageBoxService" is really just a matter of a global search and replace.  So making this a separate project is not as "inconvenient" as I first thought.

Ultimately it's just IMessageBoxService with more method signatures (I'm leaving the existing ones in, for compatibility's sake).  I can certainly send you the code once it's done and tested and you can decide whether you want to use it or not - I figure it wouldn't hurt for the built-in IMessageBoxService to support something closer to what the MessageBox offers.  I have to code it either way, so...

How do I send you the code, e-mail or some other way?


Mar 16, 2012 at 4:06 PM



Yeah with Cinch V2, its so much easier, just have IMessageBoxServiceEx in your code and use that as imports, and lets MEF do its part.


You can send me code to sacha[DOT]barber[AT]gmail[DOT]com

Apr 5, 2012 at 7:23 AM

This is now in Cinch :


Thanks for your efforts