CodeFunction.IsShared Propriedade

Definição

Define ou informa se o item é definido estaticamente ou não, ou seja, se o item é comum a todas as instâncias desse tipo de objeto ou somente a esse objeto, especificamente.

public:
 property bool IsShared { bool get(); void set(bool value); };
public:
 property bool IsShared { bool get(); void set(bool value); };
[System.Runtime.InteropServices.DispId(40)]
public bool IsShared { [System.Runtime.InteropServices.DispId(40)] get; [System.Runtime.InteropServices.DispId(40)] set; }
[<System.Runtime.InteropServices.DispId(40)>]
[<get: System.Runtime.InteropServices.DispId(40)>]
[<set: System.Runtime.InteropServices.DispId(40)>]
member this.IsShared : bool with get, set
Public Property IsShared As Boolean

Valor da propriedade

Boolean

Um valor booliano que indica true se o método é compartilhado; caso false contrário,.

Atributos

Exemplos

 Sub IsSharedExample(ByVal dte As DTE2)  

    ' Before running this example, open a code document from a project  
    ' and place the insertion point inside a function.  
    Try  
        ' Retrieve the CodeFunction at the insertion point.  
        Dim sel As TextSelection = _  
            CType(dte.ActiveDocument.Selection, TextSelection)  
        Dim fun As CodeFunction = _  
            CType(sel.ActivePoint.CodeElement( _  
            vsCMElement.vsCMElementFunction), CodeFunction)  

        If fun.IsShared Then  
            MsgBox(fun.Name & " is an instance method.")  
        Else  
            MsgBox(fun.Name & " is not an instance method.")  
        End If  
    Catch ex As Exception  
        MsgBox(ex.Message)  
    End Try  

End Sub  
 public void IsSharedExample(DTE2 dte)  
{  
    // Before running this example, open a code document from a project  
    // and place the insertion point inside a function.  
    try  
    {  
        // Retrieve the CodeFunction at the insertion point.  
        TextSelection sel =   
            (TextSelection)dte.ActiveDocument.Selection;  
        CodeFunction fun =   
            (CodeFunction)sel.ActivePoint.get_CodeElement(  
            vsCMElement.vsCMElementFunction);  

        if (fun.IsShared)  
            MessageBox.Show(fun.Name + " is an instance method.");  
        else  
            MessageBox.Show(fun.Name + " is not an instance method.");  
    }  
    catch (Exception ex)  
    {  
        MessageBox.Show(ex.Message);  
    }  
}  

Comentários

IsShared Retorna ou define se o método está associado a uma classe ou com instâncias de uma classe. Observe que essa configuração pode gerar erros dependentes de idioma. Embora IsShared o retorne com êxito, isso não significa que a alteração de código resultante seja compilada com êxito.

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).

Aplica-se a