共用方式為


VCCodeAttribute.IsReadOnly 屬性

取得包含父物件的檔案是否為唯讀。

命名空間:  Microsoft.VisualStudio.VCCodeModel
組件:  Microsoft.VisualStudio.VCCodeModel (在 Microsoft.VisualStudio.VCCodeModel.dll 中)

語法

'宣告
ReadOnly Property IsReadOnly As Boolean
bool IsReadOnly { get; }
property bool IsReadOnly {
    bool get ();
}
abstract IsReadOnly : bool with get
function get IsReadOnly () : boolean

屬性值

類型:Boolean
如果包含父物件的檔案是唯讀的,則為 true,否則為 false。

備註

如需這個範例的編譯與執行等詳細資訊,請參閱 如何:編譯 Visual C++ 程式碼模型擴充性的範例程式碼

範例

這個範例會驗證檔案是否在加入註解之前是唯讀到程式碼項目。

' Macro code.
Sub AddComment()
    Dim vcElement As VCCodeElement
    Dim vcElements As VCCodeElements
    Dim textPoint As TextPoint
    vcElements = DTE.Solution.Item(1).CodeModel.Classes
    vcElement = vcElements.Item(1)
    If (Not vcElement.IsReadOnly) Then
        vcElement.Comment = "This is a comment."
    End If
End Sub

.NET Framework 安全性

請參閱

參考

VCCodeAttribute 介面

Microsoft.VisualStudio.VCCodeModel 命名空間