本文整理汇总了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