CodeSnippetCompileUnit CodeSnippetCompileUnit CodeSnippetCompileUnit CodeSnippetCompileUnit Class

定義

表示可以加以編譯的常值 (Literal) 程式碼片段。Represents a literal code fragment that can be compiled.

public ref class CodeSnippetCompileUnit : System::CodeDom::CodeCompileUnit
[System.Runtime.InteropServices.ComVisible(true)]
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Serializable]
public class CodeSnippetCompileUnit : System.CodeDom.CodeCompileUnit
type CodeSnippetCompileUnit = class
    inherit CodeCompileUnit
Public Class CodeSnippetCompileUnit
Inherits CodeCompileUnit
繼承
CodeSnippetCompileUnitCodeSnippetCompileUnitCodeSnippetCompileUnitCodeSnippetCompileUnit
屬性

範例

下列程式碼範例示範如何使用代表常值程式碼的CodeSnippetCompileUnit字串, 建立類別的新實例。The following code example demonstrates how to create a new instance of the CodeSnippetCompileUnit class by using a string that represents literal code.

// Creates a compile unit using a literal sring;
String^ literalCode;
literalCode = "using System; namespace TestLiteralCode " +
   "{ public class TestClass { public TestClass() {} } }";
CodeSnippetCompileUnit^ csu = gcnew CodeSnippetCompileUnit( literalCode );
// Creates a compile unit using a literal sring;
string literalCode;
literalCode = "using System; namespace TestLiteralCode " + 
    "{ public class TestClass { public TestClass() {} } }";
CodeSnippetCompileUnit csu = new CodeSnippetCompileUnit( literalCode );            
' Creates a compile unit using a literal sring.
Dim literalCode As String
literalCode = "using System; namespace TestLiteralCode " & _
    "{ public class TestClass { public TestClass() {} } }"
Dim csu As New CodeSnippetCompileUnit(literalCode)

備註

CodeSnippetCompileUnit可以代表直接包含在來源中而不需修改的程式碼常值區塊。CodeSnippetCompileUnit can represent a literal block of code that is included directly in the source without modification.

會將一段程式碼以字串的形式, 完全以其原始格式儲存。CodeSnippetCompileUnitA CodeSnippetCompileUnit stores a section of code, exactly in its original format, as a string. CodeDOM 不會轉譯常值程式碼片段。The CodeDOM does not translate literal code fragments. 常值程式碼片段會以其原始格式儲存和輸出。Literal code fragments are stored and output in their original format. 系統會提供包含常值程式碼的 CodeDOM 物件, 讓開發人員可以封裝已在目的語言中的程式碼。CodeDOM objects that contain literal code are provided so developers can encapsulate code that is already in the target language.

Value屬性包含字串形式的常值程式碼片段。The Value property contains the literal code fragment as a string. LinePragma屬性是選擇性的, 而且會指定原始程式碼檔中的程式碼位置。The LinePragma property is optional and specifies the position of the code within a source code document.

建構函式

CodeSnippetCompileUnit() CodeSnippetCompileUnit() CodeSnippetCompileUnit() CodeSnippetCompileUnit()

初始化 CodeSnippetCompileUnit 類別的新執行個體。Initializes a new instance of the CodeSnippetCompileUnit class.

CodeSnippetCompileUnit(String) CodeSnippetCompileUnit(String) CodeSnippetCompileUnit(String) CodeSnippetCompileUnit(String)

初始化 CodeSnippetCompileUnit 類別的新執行個體。Initializes a new instance of the CodeSnippetCompileUnit class.

屬性

AssemblyCustomAttributes AssemblyCustomAttributes AssemblyCustomAttributes AssemblyCustomAttributes

取得已產生組件之自訂屬性的集合。Gets a collection of custom attributes for the generated assembly.

(Inherited from CodeCompileUnit)
EndDirectives EndDirectives EndDirectives EndDirectives

取得包含結尾指示詞的 CodeDirectiveCollection 物件。Gets a CodeDirectiveCollection object containing end directives.

(Inherited from CodeCompileUnit)
LinePragma LinePragma LinePragma LinePragma

取得或是設定在原始程式碼文件中,程式碼所在行和檔案的資訊。Gets or sets the line and file information about where the code is located in a source code document.

Namespaces Namespaces Namespaces Namespaces

取得命名空間的集合。Gets the collection of namespaces.

(Inherited from CodeCompileUnit)
ReferencedAssemblies ReferencedAssemblies ReferencedAssemblies ReferencedAssemblies

取得參考的組件。Gets the referenced assemblies.

(Inherited from CodeCompileUnit)
StartDirectives StartDirectives StartDirectives StartDirectives

取得包含開頭指示詞的 CodeDirectiveCollection 物件。Gets a CodeDirectiveCollection object containing start directives.

(Inherited from CodeCompileUnit)
UserData UserData UserData UserData

取得目前物件的使用者可定義資料。Gets the user-definable data for the current object.

(Inherited from CodeObject)
Value Value Value Value

取得或設定要表示的常值程式碼片段。Gets or sets the literal code fragment to represent.

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)

適用於