本文整理匯總了VB.NET中System.CodeDom.CodeAttributeArgument類的典型用法代碼示例。如果您正苦於以下問題:VB.NET CodeAttributeArgument類的具體用法?VB.NET CodeAttributeArgument怎麽用?VB.NET CodeAttributeArgument使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了CodeAttributeArgument類的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: CodeGenExample
' 導入命名空間
Imports System.CodeDom
Imports System.CodeDom.Compiler
Public Class CodeGenExample
Shared Sub Main
' Declare a new type called Class1.
Dim class1 as New CodeTypeDeclaration("Class1")
' Use attributes to mark the class as serializable and obsolete.
Dim codeAttrDecl As New CodeAttributeDeclaration("System.Serializable")
class1.CustomAttributes.Add(codeAttrDecl)
Dim codeAttr As _
New CodeAttributeArgument( new CodePrimitiveExpression("This class is obsolete."))
codeAttrDecl = New CodeAttributeDeclaration("System.Obsolete", codeAttr)
class1.CustomAttributes.Add(codeAttrDecl)
' Create a Visual Basic code provider
Dim provider As CodeDomProvider = CodeDomProvider.CreateProvider("VisualBasic")
' Generate code and send the output to the console
provider.GenerateCodeFromType(class1, Console.Out, New CodeGeneratorOptions())
End Sub
End Class
' The Visual Basic code generator produces the following source code for the preceeding example code:
'
' <System.Serializable(), _
' System.Obsolete("This class is obsolete.")> _
' Public Class Class1
' End Class