Metodo Macros.EmitMacroCode
Scrittura della riga di codice alla macro registrata.Questo metodo non deve essere utilizzato dall'interno di una macro.
Spazio dei nomi: EnvDTE
Assembly: EnvDTE (in EnvDTE.dll)
Sintassi
'Dichiarazione
Sub EmitMacroCode ( _
Code As String _
)
void EmitMacroCode(
string Code
)
void EmitMacroCode(
String^ Code
)
abstract EmitMacroCode :
Code:string -> unit
function EmitMacroCode(
Code : String
)
Parametri
- Code
Tipo: System.String
obbligatorio.La riga di codice da aggiungere alla macro.
Note
È possibile utilizzare EmitMacroCode per compilare le macro o aggiungere codice alle macro esistenti.
Questo metodo ha esito negativo se l'ambiente non è in modalità registrazione macro.EmitMacroCode deve essere utilizzato solo da componenti aggiuntivi.
Esempi
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);
}
}
Sicurezza di .NET Framework
- Attendibilità totale per il chiamante immediato. Impossibile utilizzare questo membro in codice parzialmente attendibile. Per ulteriori informazioni, vedere Utilizzo di librerie da codice parzialmente attendibile.