Export (0) Print
Expand All
Expand Minimize

LanguageService.GetIVsTextMacroHelperIfRecordingOn Method

Returns an IVsTextMacroHelper object if macro recording is turned on.

Namespace:  Microsoft.VisualStudio.Package
Assemblies:   Microsoft.VisualStudio.Package.LanguageService.9.0 (in Microsoft.VisualStudio.Package.LanguageService.9.0.dll)
  Microsoft.VisualStudio.Package.LanguageService (in Microsoft.VisualStudio.Package.LanguageService.dll)
  Microsoft.VisualStudio.Package.LanguageService.10.0 (in Microsoft.VisualStudio.Package.LanguageService.10.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.12.0 (in Microsoft.VisualStudio.Package.LanguageService.12.0.dll)
  Microsoft.VisualStudio.Package.LanguageService.11.0 (in Microsoft.VisualStudio.Package.LanguageService.11.0.dll)

public IVsTextMacroHelper GetIVsTextMacroHelperIfRecordingOn()

Return Value

Type: Microsoft.VisualStudio.TextManager.Interop.IVsTextMacroHelper
If successful, returns an IVsTextMacroHelper object; otherwise, returns a null value.

The IVsTextMacroHelper object is obtained by calling LanguageService.GetService with the GUID of the SVsTextManager service and casting the returned object to an IVsTextMacroHelper object.

The following is an example of how this method is implemented in the base LanguageService class.

namespace Microsoft.VisualStudio.Package
{
    [CLSCompliant(false), ComVisible(true)]
    public abstract class LanguageService
        : IDisposable
        , IVsLanguageInfo
        , IVsLanguageDebugInfo
        , IVsProvideColorableItems
        , IVsLanguageContextProvider
        , IOleServiceProvider
        , IObjectWithSite
        , ISynchronizeInvoke
        , IVsDebuggerEvents
        , IVsFormatFilterProvider
    { 
        public IVsTextMacroHelper GetIVsTextMacroHelperIfRecordingOn()
        {
            if (IsMacroRecordingOn()) {
                IVsTextManager textmgr = (IVsTextManager)this.GetService(
                                             typeof(SVsTextManager));
                return (IVsTextMacroHelper)textmgr;
            }
            return null;
        }
    }
}

Show:
© 2014 Microsoft