IDTCommandTarget.Exec أسلوب
Executes the specified named الأمر.
مساحة الاسم: EnvDTE
التجميع: EnvDTE (في EnvDTE.dll)
بناء الجملة
'إقرار
Sub Exec ( _
CmdName As String, _
ExecuteOption As vsCommandExecOption, _
ByRef VariantIn As Object, _
<OutAttribute> ByRef VariantOut As Object, _
<OutAttribute> ByRef Handled As Boolean _
)
void Exec(
string CmdName,
vsCommandExecOption ExecuteOption,
ref Object VariantIn,
out Object VariantOut,
out bool Handled
)
void Exec(
[InAttribute] String^ CmdName,
[InAttribute] vsCommandExecOption ExecuteOption,
[InAttribute] Object^% VariantIn,
[InAttribute] [OutAttribute] Object^% VariantOut,
[InAttribute] [OutAttribute] bool% Handled
)
abstract Exec :
CmdName:string *
ExecuteOption:vsCommandExecOption *
VariantIn:Object byref *
VariantOut:Object byref *
Handled:bool byref -> unit
function Exec(
CmdName : String,
ExecuteOption : vsCommandExecOption,
VariantIn : Object,
VariantOut : Object,
Handled : boolean
)
المعلمات
- CmdName
النوع: System.String
اسم الأمر يتم تنفيذه.
- ExecuteOption
النوع: EnvDTE.vsCommandExecOption
A vsCommandExecOption ثابت specifying the execution خيارات.
- VariantIn
النوع: System.Object%
A القيمة passed إلى the الأمر.
- VariantOut
النوع: System.Object%
A القيمة passed الخلف إلى the invoker Exec أسلوب بعد the الأمر executes.
- Handled
النوع: System.Boolean%
ملاحظات
The following مثال uses the Command كائن و its AddNamedCommand و AddControl وظائف, و the IDTCommandTarget واجهة و its (Exec و QueryStatus) وظائف, إلى demonstrate how إلى make an إضافة-في appear كـ a الأمر تشغيل the أدوات قائمة في Visual Studio. ملاحظة that this تعليمات برمجية does not work في a ماكرو.
أمثلة
Implements IDTCommandTarget
Dim applicationObject As EnvDTE.DTE
Dim addInInstance as EnvDTE.AddIn
Dim objAddIn As AddIn = CType(addInInst, AddIn)
Dim CommandObj As Command
Try
CommandObj = applicationObject.Commands.AddNamedCommand(objAddIn, "MyAddin1", "MyAddin1", "Executes the command for MyAddin1", True, 59, Nothing, 1 + 2)
'1+2 == vsCommandStatusSupported+vsCommandStatusEnabled
CommandObj.AddControl(applicationObject.CommandBars.Item("Tools"))
Catch e as System.Exception
End Try
Public Sub Exec(ByVal cmdName As String, ByVal executeOption As vsCommandExecOption, ByRef varIn As Object, ByRef varOut As Object, ByRef handled As Boolean) Implements IDTCommandTarget.Exec
handled = False
If (executeOption = vsCommandExecOption.vsCommandExecOptionDoDefault) Then
If cmdName = "MyAddin1.Connect.MyAddin1" Then
handled = True
Exit Sub
End If
End If
End Sub
Public Sub QueryStatus(ByVal cmdName As String, ByVal neededText As vsCommandStatusTextWanted, ByRef statusOption As vsCommandStatus, ByRef commandText As Object) Implements IDTCommandTarget.QueryStatus
If neededText = EnvDTE.vsCommandStatusTextWanted.vsCommandStatusTextWantedNone Then
If cmdName = "MyAddin1.Connect.MyAddin1" Then
statusOption = CType(vsCommandStatus.vsCommandStatusEnabled & vsCommandStatus.vsCommandStatusSupported, vsCommandStatus)
Else
statusOption = vsCommandStatus.vsCommandStatusUnsupported
End If
End If
End Sub
أمن NET Framework.
- الثقة الكاملة للمتصل الفوري. يتعذر استخدام هذا العضو بواسطة التعليمات البرمجية الموثوق بها جزئيًا. لمزيد من المعلومات، راجع باستخدام مكتبات من تعليمات برمجية موثوق بها جزئي.