CodeFunction.MustImplement الخاصية
Sets أو gets whether أو not the العنصر هو declared abstract و thus يتطلب an implementation.
مساحة الاسم: EnvDTE
التجميع: EnvDTE (في EnvDTE.dll)
بناء الجملة
'إقرار
Property MustImplement As Boolean
Get
Set
bool MustImplement { get; set; }
property bool MustImplement {
bool get ();
void set (bool value);
}
abstract MustImplement : bool with get, set
function get MustImplement () : boolean
function set MustImplement (value : boolean)
قيمة الخاصية
النوع: System.Boolean
A منطقي القيمة indicating true if the أسلوب هو declared abstract و thus يتطلب an implementation; false if otherwise.
ملاحظات
MustImplement إرجاع أو sets whether the أسلوب هو implemented أو يتطلب an implementation في subclasses. ملاحظة that this might دوماً be False for some languages, و that إعداد MustImplement might فشل depending تشغيل the اللغة.
ملاحظة
قيم عناصر نموذج تعليمات برمجية مثل فئات بنيات، الدالات، السمات، مفوضين وما إلى ذلك يمكن أن تكون غير محدداً بعد إجراء أنواع معينة من عمليات التحرير، مما يعني أن لا يكون relied قيمها على إلى دائماً تبقى كما هي. لمزيد من في تشكيل، راجع مقطع "تعليمات برمجية طراز عنصر قيم يمكن تغيير" في اكتشاف التعليمات البرمجية باستخدام "نموذج التعليمات البرمجية" (Visual Basic).
أمثلة
Sub MustImplementExample(ByVal dte As DTE2)
' Before running this example, open a code document from a project
' and place the insertion point inside a class definition.
Try
' Retrieve the CodeClass at the insertion point.
Dim sel As TextSelection = _
CType(dte.ActiveDocument.Selection, TextSelection)
Dim cls As CodeClass = _
CType(sel.ActivePoint.CodeElement( _
vsCMElement.vsCMElementClass), CodeClass)
Dim mustImpl As String
Dim elem As CodeElement
For Each elem In cls.Members
If (elem.Kind = vsCMElement.vsCMElementFunction) Then
Dim fun As CodeFunction = CType(elem, CodeFunction)
If fun.MustImplement Then
mustImpl &= fun.Prototype( _
vsCMPrototype.vsCMPrototypeParamNames Or _
vsCMPrototype.vsCMPrototypeParamTypes Or _
vsCMPrototype.vsCMPrototypeType) & vbCrLf
End If
End If
Next
MsgBox(cls.Name & " has the following abstract methods:" & _
vbCrLf & vbCrLf & mustImpl)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
public void MustImplementExample(DTE2 dte)
{
// Before running this example, open a code document from a project
// and place the insertion point inside a class definition.
try
{
// Retrieve the CodeClass at the insertion point.
TextSelection sel =
(TextSelection)dte.ActiveDocument.Selection;
CodeClass cls =
(CodeClass)sel.ActivePoint.get_CodeElement(
vsCMElement.vsCMElementClass);
string mustImpl = "";
foreach (CodeElement elem in cls.Members)
{
if (elem.Kind == vsCMElement.vsCMElementFunction)
{
CodeFunction fun = (CodeFunction)elem;
if (fun.MustImplement)
mustImpl += fun.get_Prototype(
(int)(vsCMPrototype.vsCMPrototypeParamNames |
vsCMPrototype.vsCMPrototypeParamTypes |
vsCMPrototype.vsCMPrototypeType)) + "\n";
}
}
MessageBox.Show(cls.Name +
" has the following abstract methods:\n\n" + mustImpl);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
أمن NET Framework.
- الثقة الكاملة للمتصل الفوري. يتعذر استخدام هذا العضو بواسطة التعليمات البرمجية الموثوق بها جزئيًا. لمزيد من المعلومات، راجع باستخدام مكتبات من تعليمات برمجية موثوق بها جزئي.
راجع أيضًَا
المرجع
موارد أخرى
كيفية: الترجمة وإعادة تشغيل أمثلة التعليمات البرمجية لطراز كائن التنفيذ التلقائي
اكتشاف التعليمات البرمجية باستخدام "نموذج التعليمات البرمجية" (Visual Basic)
اكتشاف التعليمات البرمجية باستخدام "نموذج التعليمات البرمجية" (Visual C#)