CodeFunction.MustImplement Свойство
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Задает или возвращает значение, указывающее, объявлен ли элемент как абстрактный и, соответственно, требует ли он реализации.
public:
property bool MustImplement { bool get(); void set(bool value); };
public:
property bool MustImplement { bool get(); void set(bool value); };
[System.Runtime.InteropServices.DispId(41)]
public bool MustImplement { [System.Runtime.InteropServices.DispId(41)] get; [System.Runtime.InteropServices.DispId(41)] set; }
[<System.Runtime.InteropServices.DispId(41)>]
[<get: System.Runtime.InteropServices.DispId(41)>]
[<set: System.Runtime.InteropServices.DispId(41)>]
member this.MustImplement : bool with get, set
Public Property MustImplement As Boolean
Значение свойства
Логическое значение true, если метод объявлен абстрактным и, значит, требует реализации; в противном случае — false.
- Атрибуты
Примеры
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);
}
}
Комментарии
MustImplement Возвращает или задает, реализован ли метод или требует реализации в подклассах. Обратите внимание, что это может быть всегда False для некоторых языков, и этот параметр MustImplement может завершиться ошибкой в зависимости от языка.
Примечание
Значения элементов модели кода, таких как классы, структуры, функции, атрибуты, делегаты и другие, после внесения некоторых изменений могут оказаться недетерминированными, другими словами, нельзя рассчитывать, что их значения будут всегда оставаться одинаковыми. Дополнительные сведения см. в разделе значения элементов модели кода могут изменяться при обнаружении кода с помощью модели кода (Visual Basic).