CodeSnippetStatement 类

定义

使用原义代码片段表示一条语句。Represents a statement using a literal code fragment.

public ref class CodeSnippetStatement : System::CodeDom::CodeStatement
[System.Runtime.InteropServices.ComVisible(true)]
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.AutoDispatch)]
[System.Serializable]
public class CodeSnippetStatement : System.CodeDom.CodeStatement
type CodeSnippetStatement = class
    inherit CodeStatement
Public Class CodeSnippetStatement
Inherits CodeStatement
继承
CodeSnippetStatement
属性

示例

下面的示例使用原义代码片段CodeSnippetStatement创建类的实例。The following example creates an instance of the CodeSnippetStatement class using a literal code fragment. 此代码示例是为CodeRegionDirective类提供的更大示例的一部分。This code example is part of a larger example provided for the CodeRegionDirective class.

CodeSnippetStatement snippet1 = new CodeSnippetStatement();
snippet1.Value = "            Console.WriteLine(field1);";

CodeRegionDirective regionStart = new CodeRegionDirective(CodeRegionMode.End, "");
regionStart.RegionText = "Snippet Region";
regionStart.RegionMode = CodeRegionMode.Start;
snippet1.StartDirectives.Add(regionStart);
snippet1.EndDirectives.Add(new CodeRegionDirective(CodeRegionMode.End, string.Empty));
Dim snippet1 As New CodeSnippetStatement()
snippet1.Value = "            Console.WriteLine(field1)"

Dim regionStart As New CodeRegionDirective(CodeRegionMode.End, "")
regionStart.RegionText = "Snippet Region"
regionStart.RegionMode = CodeRegionMode.Start
snippet1.StartDirectives.Add(regionStart)
snippet1.EndDirectives.Add(New CodeRegionDirective(CodeRegionMode.End, String.Empty))

注解

CodeSnippetStatement可以使用原义代码片段表示语句, 而无需进行修改即可直接包含在源中。CodeSnippetStatement can represent a statement using a literal code fragment that will be included directly in the source without modification.

以字符串的形式存储代码的一部分,其原始格式完全相同。CodeSnippetStatementA CodeSnippetStatement 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 for the snippet statement.

构造函数

CodeSnippetStatement()

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

CodeSnippetStatement(String)

使用指定的代码片段初始化 CodeSnippetStatement 类的新实例。Initializes a new instance of the CodeSnippetStatement class using the specified code fragment.

属性

EndDirectives

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

(继承自 CodeStatement)
LinePragma

获取或设置代码语句所在的行。Gets or sets the line on which the code statement occurs.

(继承自 CodeStatement)
StartDirectives

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

(继承自 CodeStatement)
UserData

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

(继承自 CodeObject)
Value

获取或设置原义代码片段语句。Gets or sets the literal code fragment statement.

方法

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)

适用于