Click here to Skip to main content
15,886,676 members
Articles / All Topics

MoXAML goes MefXAML

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
6 Sep 2011CPOL1 min read 10.9K   1  
MoXAML Power Toys gets that MEF injection to make it plugin based.

First of all, I must apologize that it’s taken me so long to release the new version of MoXAML. Unfortunately, it’s taken a back burner to other projects that I have going on, so it’s been lower down on my priority list than I would have liked. Saying that, I have been tinkering with a new version and making changes to the internal architecture to make it easier for me to add new functionality to it. MoXAML has now got the MEF mojo underpinning it.

A feature of the original version of MoXAML that I was never happy with was the way I had to register commands so that they will appear in the menus. To be honest, the code was a complete mess and it offended my sensibilities whenever I looked at it. Well, the new version has completely changed that. I’ve added a MoXAML.Infrastructure library that provides a lot of the underpinnings of MoXAML registration; all we need to do is derive from the CommandBase class in this library and with just a couple of commands, we are good to go.

First of all, we need to add a unique command name, the menu text and the parent command that we want to show this command in. This just gets added into the constructor likes so:

C#
public MyConstructor()
{
  CommandName = "MyUniqueCommandName";
  Caption = "Menu text";
  ParentCommandBar.Add(CommandBarType.SolutionContextMenu);
}

Now, to add the code to actually do the work, just override the Execute method and add in the functionality that you want to perform.

In a future post, I’ll cover creating an add-in from scratch and talk about the API that’s now been exposed in MoXAML. To get the latest version of MoXAML, please check it out here.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
CEO
United Kingdom United Kingdom
A developer for over 30 years, I've been lucky enough to write articles and applications for Code Project as well as the Intel Ultimate Coder - Going Perceptual challenge. I live in the North East of England with 2 wonderful daughters and a wonderful wife.

I am not the Stig, but I do wish I had Lotus Tuned Suspension.

Comments and Discussions

 
-- There are no messages in this forum --