问题
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".
回答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.
回答2:
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 objectITextSelection.SelectionChanged
- raised whenever the selection changes (though not for the empty-selection tracking the caret)
回答3:
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.
来源:https://stackoverflow.com/questions/2977272/visual-studio-2010-with-managed-extensiblity-framework