Sdílet prostřednictvím


Macros.EmitMacroCode – metoda

Zapíše zaznamenanou makro řádku kódu. Tato metoda měla použít z v makru.

Obor názvů:  EnvDTE
Sestavení:  EnvDTE (v EnvDTE.dll)

Syntaxe

'Deklarace
Sub EmitMacroCode ( _
    Code As String _
)
void EmitMacroCode(
    string Code
)
void EmitMacroCode(
    String^ Code
)
abstract EmitMacroCode : 
        Code:string -> unit 
function EmitMacroCode(
    Code : String
)

Parametry

Poznámky

Můžete použít EmitMacroCode vytvářet makra nebo přidat kód existující makra.

Tato metoda selže, pokud není v režimu záznamu makra prostředí. EmitMacroCodeměli používat pouze z doplňků.

Příklady

public void CodeExample(DTE2 dte, AddIn addin)
{
    // INSTRUCTIONS: Run this code, open a solution, start
    // recording a macro, then connect the add-in containing this code.
    try
    {
        Macros mac = dte.Macros;
        if (mac.IsRecording)
        {
            mac.Pause();
            if (!mac.IsRecording)
                mac.Resume();
            mac.EmitMacroCode("rem Code added by the EmitMacroCode method");
            // Demonstrate these two properties return the same reference.
            bool test = mac.DTE.Equals(mac.Parent);
            if (test) MessageBox.Show("The DTE and Parent property refer to the same object.");
            else MessageBox.Show("The DTE and Parent property do not refer to the same object.");
        }
        else MessageBox.Show("Start a macro recording session and reconnect addin");
    }
    catch(Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

Zabezpečení rozhraní .NET Framework

Viz také

Odkaz

Macros Rozhraní

EnvDTE – obor názvů

Další zdroje

Automating Repetitive Actions by Using Macros