CodeSnippetCompileUnit 类

定义

表示可编译的原义代码片段。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
继承
CodeSnippetCompileUnit
属性

示例

下面的代码示例演示如何使用表示原义代码的字符串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 类的新实例。Initializes a new instance of the CodeSnippetCompileUnit class.

CodeSnippetCompileUnit(String)

初始化 CodeSnippetCompileUnit 类的新实例。Initializes a new instance of the CodeSnippetCompileUnit class.

属性

AssemblyCustomAttributes

获取生成的程序集的自定义特性集合。Gets a collection of custom attributes for the generated assembly.

(继承自 CodeCompileUnit)
EndDirectives

获取包含结束指令的 CodeDirectiveCollection 对象。Gets a CodeDirectiveCollection object containing end directives.

(继承自 CodeCompileUnit)
LinePragma

获取或设置有关代码在源代码文档中的位置的行信息和文件信息。Gets or sets the line and file information about where the code is located in a source code document.

Namespaces

获取命名空间的集合。Gets the collection of namespaces.

(继承自 CodeCompileUnit)
ReferencedAssemblies

获取引用的程序集。Gets the referenced assemblies.

(继承自 CodeCompileUnit)
StartDirectives

获取包含开始指令的 CodeDirectiveCollection 对象。Gets a CodeDirectiveCollection object containing start directives.

(继承自 CodeCompileUnit)
UserData

获取当前对象的用户可定义数据。Gets the user-definable data for the current object.

(继承自 CodeObject)
Value

获取或设置要表示的原义代码片段。Gets or sets the literal code fragment to represent.

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

适用于