次の方法で共有


CodeFunction2.MustImplement プロパティ

項目が抽象項目として宣言され、実装が必要かどうかを示す値を取得または設定します。

名前空間:  EnvDTE80
アセンブリ:  EnvDTE80 (EnvDTE80.dll 内)

構文

'宣言
Property MustImplement As Boolean
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)

プロパティ値

型 : Boolean
メソッドが抽象メソッドとして宣言され、実装が必要である場合は true、それ以外の場合は false となるブール値。

解説

MustImplement 返すかどうかをメソッドは実装またはそのサブクラスで実装が必要です。 一部の言語を常にある注意してください。 false, 、およびその設定 MustImplement 言語に応じて、失敗する可能性があります。

注意

クラス、構造体、関数、属性、デリゲートなどのコード モデル要素の値は、特定の種類の編集を行った後、非確定的になることがあります。つまり、これらの値が常に同じであることを前提にすることはできません。詳細については、コード モデル要素の値で変更できるセクションを参照してください。 コード モデルを使用したコードの調査 (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 セキュリティ

  • 直前の呼び出し元に対する完全な信頼。このメンバーは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

関連項目

CodeFunction2 インターフェイス

EnvDTE80 名前空間

その他の技術情報

方法 : オートメーション オブジェクト モデルのコード例をコンパイルおよび実行する

コード モデルを使用したコードの調査 (Visual Basic)

コード モデルを使用したコードの調査 (Visual C#)