1

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".

David Basarab
  • 72,212
  • 42
  • 129
  • 156
NewProgrammer
  • 121
  • 1
  • 4
  • Could you give a little more detail as to what you're trying to accomplish? What do you mean by "passively and in real-time?" – David Neale Jun 04 '10 at 19:52
  • Sorry about that. I meant is that I want my code to work the time IDE is running. When I highlight a section of text, I want my code to log the selected text to a file on it's own, without the user manually logging it himself. – NewProgrammer Jun 04 '10 at 19:57

3 Answers3

1

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
  • 117,631
  • 17
  • 236
  • 300
1

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)

Community
  • 1
  • 1
Noah Richards
  • 6,777
  • 2
  • 31
  • 28
0

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
  • 15,015
  • 14
  • 88
  • 147
  • 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 Jun 04 '10 at 21:05
  • No problem buddy. I would use a C# MouseEvent Listener and the C# TextPattern.GetSelection Method I mentioned above. – Stephan Kristyn Jun 04 '10 at 21:34