views:

130

answers:

4

I've been looking into into MEF (Managed Extensibility Framework), but I am not entirely sure if it is something that I need and can help me accommplish what I need to do.

Can someone provide an easy to understand description of MEF, provides good resources and tutorials (aside from MSDN), and/or know if it can do the task I am trying to do under Visual Studio?

The task I am trying to do is to "log" a string of text to a text file whenever the user selects a string of text. I also need this functionality to run passively and real-time, which Visual Studio Add-in's do not support this functionality, as their behavior is "click the button to work".

A: 

Can someone provide an easy to understand description of MEF

MEF will let you build applications that you can extend at run time. One example of an app that can do that would be Visual Studio: see the list of stuff that appears on the right side of the splash screen when VS starts? Those are separate applications that run in VS.

The task I am trying to do is to "log" a string of text to a text file whenever the user selects a string of text.

I think you'll need to download and use the VS SDK to do this. Based on some quick checking, the events you'd want to listen for are available only much "closer to the metal."

Tangurena
closer to metal? I don't understand and googling it mention's about AMD's steam SDK
NewProgrammer
"Closer to the metal" means that you are having to write code closer the physical stuff. For example if you were working with the OSI model, layer 7 is nice and abstract, layer 1 is the actual hardware made of metal and bits. When your networking code needs you to write your own TCP protocols, you are getting closer to the metal.
Tangurena
A: 

It looks like the docs here

http://msdn.microsoft.com/en-us/library/dd885240(v=VS.100).aspx

may be one useful starting point.

Brian
A: 

I'm sure this is possible in .NET without going 'close to the metal', probably a reference to 'lower level code'. The .NET Method TextPattern.GetSelection Method will help you to accomplish your task if combined with a MouseEvent Handler.

Stephan Kristyn
Thanks you for the help Stephan, but the purpose I am doing this is to code it for Visual Studio 2010 as an extension, and I write it in C#. Since MEF appears to one of my solutions, I need some assistance on it, as I am still new to Visual Studio Add-in and MEF Extensiblity APIs
NewProgrammer
No problem buddy. I would use a C# MouseEvent Listener and the C# TextPattern.GetSelection Method I mentioned above.
Stephan Kristyn
A: 

See my response to a similar question.

The answer is "yes", this is possible/supported. Look for the following in samples/documentation/walkthroughs:

IWpfTextViewCreationLister - for detecting when editor instances are created.
ITextView.Selection - the selection object
ITextSelection.SelectionChanged - raised whenever the selection changes (though not for the empty-selection tracking the caret)

Noah Richards