CodeCommentStatement 생성자
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
CodeCommentStatement 클래스의 새 인스턴스를 초기화합니다.
오버로드
CodeCommentStatement() |
CodeCommentStatement 클래스의 새 인스턴스를 초기화합니다. |
CodeCommentStatement(CodeComment) |
지정된 주석을 사용하여 CodeCommentStatement 클래스의 새 인스턴스를 초기화합니다. |
CodeCommentStatement(String) |
지정된 텍스트를 내용으로 사용하여 CodeCommentStatement 클래스의 새 인스턴스를 초기화합니다. |
CodeCommentStatement(String, Boolean) |
지정된 텍스트 및 문서 주석 플래그를 사용하여 CodeCommentStatement 클래스의 새 인스턴스를 초기화합니다. |
CodeCommentStatement()
- Source:
- CodeCommentStatement.cs
- Source:
- CodeCommentStatement.cs
- Source:
- CodeCommentStatement.cs
CodeCommentStatement 클래스의 새 인스턴스를 초기화합니다.
public:
CodeCommentStatement();
public CodeCommentStatement ();
Public Sub New ()
적용 대상
CodeCommentStatement(CodeComment)
- Source:
- CodeCommentStatement.cs
- Source:
- CodeCommentStatement.cs
- Source:
- CodeCommentStatement.cs
지정된 주석을 사용하여 CodeCommentStatement 클래스의 새 인스턴스를 초기화합니다.
public:
CodeCommentStatement(System::CodeDom::CodeComment ^ comment);
public CodeCommentStatement (System.CodeDom.CodeComment comment);
new System.CodeDom.CodeCommentStatement : System.CodeDom.CodeComment -> System.CodeDom.CodeCommentStatement
Public Sub New (comment As CodeComment)
매개 변수
- comment
- CodeComment
주석을 나타내는 CodeComment입니다.
적용 대상
CodeCommentStatement(String)
- Source:
- CodeCommentStatement.cs
- Source:
- CodeCommentStatement.cs
- Source:
- CodeCommentStatement.cs
지정된 텍스트를 내용으로 사용하여 CodeCommentStatement 클래스의 새 인스턴스를 초기화합니다.
public:
CodeCommentStatement(System::String ^ text);
public CodeCommentStatement (string text);
new System.CodeDom.CodeCommentStatement : string -> System.CodeDom.CodeCommentStatement
Public Sub New (text As String)
매개 변수
- text
- String
주석의 내용입니다.
적용 대상
CodeCommentStatement(String, Boolean)
- Source:
- CodeCommentStatement.cs
- Source:
- CodeCommentStatement.cs
- Source:
- CodeCommentStatement.cs
지정된 텍스트 및 문서 주석 플래그를 사용하여 CodeCommentStatement 클래스의 새 인스턴스를 초기화합니다.
public:
CodeCommentStatement(System::String ^ text, bool docComment);
public CodeCommentStatement (string text, bool docComment);
new System.CodeDom.CodeCommentStatement : string * bool -> System.CodeDom.CodeCommentStatement
Public Sub New (text As String, docComment As Boolean)
매개 변수
- text
- String
주석의 내용입니다.
- docComment
- Boolean
주석이 문서 주석이면 true
이고 그렇지 않으면 false
입니다.
예제
다음 코드 예제에서는 XML 주석 필드로 사용할 주석 문을 만드는 생성자를 사용 CodeCommentStatement(String, Boolean) 하는 방법을 보여 줍니다. 이 예제는 다음과 같은 더 큰 예제의 일부입니다.
// Declare a new code entry point method.
CodeEntryPointMethod start = new CodeEntryPointMethod();
start.Comments.Add(new CodeCommentStatement("<summary>", true));
start.Comments.Add(new CodeCommentStatement(
"Main method for HelloWorld application.", true));
start.Comments.Add(new CodeCommentStatement(
@"<para>Add a new paragraph to the description.</para>", true));
start.Comments.Add(new CodeCommentStatement("</summary>", true));
' Declare a new code entry point method.
Dim start As New CodeEntryPointMethod()
start.Comments.Add(New CodeCommentStatement("<summary>", True))
start.Comments.Add(New CodeCommentStatement( _
"Main method for HelloWorld application.", True))
start.Comments.Add(New CodeCommentStatement( _
"<para>Add a new paragraph to the description.</para>", True))
start.Comments.Add(New CodeCommentStatement("</summary>", True))
다음 코드 예제는 간단한 "Hello World" 콘솔 애플리케이션 만들기 및 컴파일된 애플리케이션에 대 한 XML 문서 파일의 생성 방법을 보여 줍니다.
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.IO;
using System.Text.RegularExpressions;
namespace BasicCodeDomApp
{
class Program
{
static string providerName = "cs";
static string sourceFileName = "test.cs";
static void Main(string[] args)
{
CodeDomProvider provider = CodeDomProvider.CreateProvider(providerName);
LogMessage("Building CodeDOM graph...");
CodeCompileUnit cu = new CodeCompileUnit();
cu = BuildHelloWorldGraph();
StreamWriter sourceFile = new StreamWriter(sourceFileName);
provider.GenerateCodeFromCompileUnit(cu, sourceFile, null);
sourceFile.Close();
CompilerParameters opt = new CompilerParameters(new string[]{
"System.dll" });
opt.GenerateExecutable = true;
opt.OutputAssembly = "HelloWorld.exe";
opt.TreatWarningsAsErrors = true;
opt.IncludeDebugInformation = true;
opt.GenerateInMemory = true;
opt.CompilerOptions = "/doc:HelloWorldDoc.xml";
CompilerResults results;
LogMessage("Compiling with " + providerName);
results = provider.CompileAssemblyFromFile(opt, sourceFileName);
OutputResults(results);
if (results.NativeCompilerReturnValue != 0)
{
LogMessage("");
LogMessage("Compilation failed.");
}
else
{
LogMessage("");
LogMessage("Demo completed successfully.");
}
File.Delete(sourceFileName);
}
// Build a Hello World program graph using System.CodeDom types.
public static CodeCompileUnit BuildHelloWorldGraph()
{
// Create a new CodeCompileUnit to contain
// the program graph.
CodeCompileUnit compileUnit = new CodeCompileUnit();
// Declare a new namespace called Samples.
CodeNamespace samples = new CodeNamespace("Samples");
// Add the new namespace to the compile unit.
compileUnit.Namespaces.Add(samples);
// Add the new namespace import for the System namespace.
samples.Imports.Add(new CodeNamespaceImport("System"));
// Declare a new type called Class1.
CodeTypeDeclaration class1 = new CodeTypeDeclaration("Class1");
class1.Comments.Add(new CodeCommentStatement("<summary>", true));
class1.Comments.Add(new CodeCommentStatement(
"Create a Hello World application.", true));
class1.Comments.Add(new CodeCommentStatement("</summary>", true));
class1.Comments.Add(new CodeCommentStatement(
@"<seealso cref=" + '"' + "Class1.Main" + '"' + "/>", true));
// Add the new type to the namespace type collection.
samples.Types.Add(class1);
// Declare a new code entry point method.
CodeEntryPointMethod start = new CodeEntryPointMethod();
start.Comments.Add(new CodeCommentStatement("<summary>", true));
start.Comments.Add(new CodeCommentStatement(
"Main method for HelloWorld application.", true));
start.Comments.Add(new CodeCommentStatement(
@"<para>Add a new paragraph to the description.</para>", true));
start.Comments.Add(new CodeCommentStatement("</summary>", true));
// Create a type reference for the System.Console class.
CodeTypeReferenceExpression csSystemConsoleType =
new CodeTypeReferenceExpression("System.Console");
// Build a Console.WriteLine statement.
CodeMethodInvokeExpression cs1 = new CodeMethodInvokeExpression(
csSystemConsoleType, "WriteLine",
new CodePrimitiveExpression("Hello World!"));
// Add the WriteLine call to the statement collection.
start.Statements.Add(cs1);
// Build another Console.WriteLine statement.
CodeMethodInvokeExpression cs2 = new CodeMethodInvokeExpression(
csSystemConsoleType, "WriteLine", new CodePrimitiveExpression(
"Press the ENTER key to continue."));
// Add the WriteLine call to the statement collection.
start.Statements.Add(cs2);
// Build a call to System.Console.ReadLine.
CodeMethodInvokeExpression csReadLine =
new CodeMethodInvokeExpression(csSystemConsoleType, "ReadLine");
// Add the ReadLine statement.
start.Statements.Add(csReadLine);
// Add the code entry point method to
// the Members collection of the type.
class1.Members.Add(start);
return compileUnit;
}
static void LogMessage(string text)
{
Console.WriteLine(text);
}
static void OutputResults(CompilerResults results)
{
LogMessage("NativeCompilerReturnValue=" +
results.NativeCompilerReturnValue.ToString());
foreach (string s in results.Output)
{
LogMessage(s);
}
}
}
}
Imports System.CodeDom
Imports System.CodeDom.Compiler
Imports System.IO
Imports System.Text.RegularExpressions
Class Program
Private Shared providerName As String = "vb"
Private Shared sourceFileName As String = "test.vb"
Shared Sub Main(ByVal args() As String)
Dim provider As CodeDomProvider = _
CodeDomProvider.CreateProvider(providerName)
LogMessage("Building CodeDOM graph...")
Dim cu As New CodeCompileUnit()
cu = BuildHelloWorldGraph()
Dim sourceFile As New StreamWriter(sourceFileName)
LogMessage("Generating code...")
provider.GenerateCodeFromCompileUnit(cu, sourceFile, Nothing)
sourceFile.Close()
Dim opt As New CompilerParameters(New String() {"System.dll"})
opt.GenerateExecutable = True
opt.OutputAssembly = "HelloWorld.exe"
opt.TreatWarningsAsErrors = True
opt.IncludeDebugInformation = True
opt.GenerateInMemory = True
opt.CompilerOptions = "/doc"
Dim results As CompilerResults
LogMessage(("Compiling with " & providerName))
results = provider.CompileAssemblyFromFile(opt, sourceFileName)
OutputResults(results)
If results.NativeCompilerReturnValue <> 0 Then
LogMessage("")
LogMessage("Compilation failed.")
Else
LogMessage("")
LogMessage("Demo completed successfully.")
End If
File.Delete(sourceFileName)
End Sub
' Build a Hello World program graph using
' System.CodeDom types.
Public Shared Function BuildHelloWorldGraph() As CodeCompileUnit
' Create a new CodeCompileUnit to contain
' the program graph.
Dim compileUnit As New CodeCompileUnit()
' Declare a new namespace called Samples.
Dim samples As New CodeNamespace("Samples")
' Add the new namespace to the compile unit.
compileUnit.Namespaces.Add(samples)
' Add the new namespace import for the System namespace.
samples.Imports.Add(New CodeNamespaceImport("System"))
' Declare a new type called Class1.
Dim class1 As New CodeTypeDeclaration("Class1")
class1.Comments.Add(New CodeCommentStatement("<summary>", True))
class1.Comments.Add(New CodeCommentStatement( _
"Create a Hello World application.", True))
class1.Comments.Add(New CodeCommentStatement("</summary>", True))
class1.Comments.Add(New CodeCommentStatement( _
"<seealso cref=" & ControlChars.Quote & "Class1.Main" & _
ControlChars.Quote & "/>", True))
' Add the new type to the namespace type collection.
samples.Types.Add(class1)
' Declare a new code entry point method.
Dim start As New CodeEntryPointMethod()
start.Comments.Add(New CodeCommentStatement("<summary>", True))
start.Comments.Add(New CodeCommentStatement( _
"Main method for HelloWorld application.", True))
start.Comments.Add(New CodeCommentStatement( _
"<para>Add a new paragraph to the description.</para>", True))
start.Comments.Add(New CodeCommentStatement("</summary>", True))
' Create a type reference for the System.Console class.
Dim csSystemConsoleType As New CodeTypeReferenceExpression( _
"System.Console")
' Build a Console.WriteLine statement.
Dim cs1 As New CodeMethodInvokeExpression(csSystemConsoleType, _
"WriteLine", New CodePrimitiveExpression("Hello World!"))
' Add the WriteLine call to the statement collection.
start.Statements.Add(cs1)
' Build another Console.WriteLine statement.
Dim cs2 As New CodeMethodInvokeExpression(csSystemConsoleType, _
"WriteLine", New CodePrimitiveExpression( _
"Press the ENTER key to continue."))
' Add the WriteLine call to the statement collection.
start.Statements.Add(cs2)
' Build a call to System.Console.ReadLine.
Dim csReadLine As New CodeMethodInvokeExpression( _
csSystemConsoleType, "ReadLine")
' Add the ReadLine statement.
start.Statements.Add(csReadLine)
' Add the code entry point method to
' the Members collection of the type.
class1.Members.Add(start)
Return compileUnit
End Function 'BuildHelloWorldGraph
Shared Sub LogMessage(ByVal [text] As String)
Console.WriteLine([text])
End Sub
Shared Sub OutputResults(ByVal results As CompilerResults)
LogMessage(("NativeCompilerReturnValue=" & _
results.NativeCompilerReturnValue.ToString()))
Dim s As String
For Each s In results.Output
LogMessage(s)
Next s
End Sub
End Class
설명
매개 변수가 이 docComment
면 는 CodeCommentStatementtrue
설명서 주석이고 주석은 삼중 구분 기호 문자를 사용하여 구조화됩니다. 예를 들어 C#의 주석은 Visual Basic "///
"에서 "'''
"입니다. 문서 주석은 요소로 식별 <summary>
된 형식 또는 멤버 요약과 같은 XML 주석 필드를 식별하는 데 사용됩니다.
적용 대상
.NET