CodeFunction.MustImplement Propriedade
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Define ou obtém se o item é declarado abstrato e, portanto, requer uma implementação.
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
Valor da propriedade
Um valor booliano que indica true se o método é declarado abstrato e, portanto, requer uma implementação; false caso contrário,.
- Atributos
Exemplos
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);
}
}
Comentários
MustImplement Retorna ou define se o método é implementado ou requer uma implementação em subclasses. Observe que isso pode ser sempre False para alguns idiomas, e essa configuração MustImplement pode falhar dependendo do idioma.
Observação
Os valores dos elementos de modelo de código, como classes, structs, funções, atributos, delegados e assim por diante, podem ser não determinísticos depois de fazer determinados tipos de edições, o que significa que seus valores não podem ser dependentes para sempre permanecerem os mesmos. Para obter mais informações, consulte os valores de elemento de modelo de código de seção podem ser alterados na descoberta de código usando o modelo de código (Visual Basic).