本文整理汇总了VB.NET中System.CodeDom.Compiler.GeneratedCodeAttribute类的典型用法代码示例。如果您正苦于以下问题:VB.NET GeneratedCodeAttribute类的具体用法?VB.NET GeneratedCodeAttribute怎么用?VB.NET GeneratedCodeAttribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GeneratedCodeAttribute类的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")
' Declare a new generated code attribute
Dim generatedCodeAttribute As _
New GeneratedCodeAttribute("SampleCodeGenerator", "2.0.0.0")
' Use the generated code attribute members in the attribute declaration
Dim codeAttrDecl As _
New CodeAttributeDeclaration(generatedCodeAttribute.GetType().Name,
New CodeAttributeArgument(
New CodePrimitiveExpression(generatedCodeAttribute.Tool)),
New CodeAttributeArgument(
New CodePrimitiveExpression(generatedCodeAttribute.Version)))
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:
'
' <GeneratedCodeAttribute("SampleCodeGenerator", "2.0.0.0")> _
' Public Class Class1
' End Class