当前位置: 首页>>代码示例>>VB.NET>>正文


VB.NET ManagementClass.GetStronglyTypedClassCode方法代码示例

本文整理汇总了VB.NET中System.Management.ManagementClass.GetStronglyTypedClassCode方法的典型用法代码示例。如果您正苦于以下问题:VB.NET ManagementClass.GetStronglyTypedClassCode方法的具体用法?VB.NET ManagementClass.GetStronglyTypedClassCode怎么用?VB.NET ManagementClass.GetStronglyTypedClassCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。


在下文中一共展示了ManagementClass.GetStronglyTypedClassCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。

示例1: Main

' 导入命名空间
Imports System.Management
Imports System.CodeDom
Imports System.IO
Imports System.CodeDom.Compiler
Imports System.Security.Permissions

Namespace Sample

    <EnvironmentPermissionAttribute(SecurityAction.LinkDemand)> _
    Public Class GenerateVBCode

        <EnvironmentPermissionAttribute(SecurityAction.LinkDemand)> _
                Public Overloads Shared Function _
                    Main(ByVal args() As String) As Integer

            Dim strFilePath As String
            strFilePath = "C:\temp\LogicalDisk.vb"
            Dim ClsDom As CodeTypeDeclaration

            Dim cls1 As ManagementClass
            cls1 = New ManagementClass( _
                Nothing, "Win32_LogicalDisk", Nothing)
            ClsDom = cls1.GetStronglyTypedClassCode(False, False)


            Dim cg As ICodeGenerator
            cg = (New VBCodeProvider).CreateGenerator()
            Dim cn As CodeNamespace
            cn = New CodeNamespace("TestNamespace")

            ' Add any imports to the code
            cn.Imports.Add( _
                New CodeNamespaceImport("System"))
            cn.Imports.Add( _
                New CodeNamespaceImport("System.ComponentModel"))
            cn.Imports.Add( _
                New CodeNamespaceImport("System.Management"))
            cn.Imports.Add( _
                New CodeNamespaceImport("System.Collections"))

            ' Add class to the namespace
            cn.Types.Add(ClsDom)

            ' Now create the filestream (output file)
            Dim tw As TextWriter
            tw = New StreamWriter(New _
                FileStream(strFilePath, FileMode.Create))

            Dim options As New CodeGeneratorOptions
            ' And write it to the file
            cg.GenerateCodeFromNamespace( _
            cn, tw, options)

            tw.Close()

        End Function
    End Class
End Namespace
开发者ID:VB.NET开发者,项目名称:System.Management,代码行数:59,代码来源:ManagementClass.GetStronglyTypedClassCode

示例2: GenerateVBCode

' 导入命名空间
Imports System.Management
Imports System.CodeDom
Imports System.IO
Imports System.CodeDom.Compiler

Class GenerateVBCode

    Public Overloads Shared Function _
        Main(ByVal args() As String) As Integer

        Dim cls1 As ManagementClass
        cls1 = New ManagementClass( _
            Nothing, "Win32_LogicalDisk", Nothing)
        cls1.GetStronglyTypedClassCode( _
            CodeLanguage.VB, _
            "C:\temp\Logicaldisk.vb", _
            String.Empty)

    End Function
End Class
开发者ID:VB.NET开发者,项目名称:System.Management,代码行数:21,代码来源:ManagementClass.GetStronglyTypedClassCode


注:本文中的System.Management.ManagementClass.GetStronglyTypedClassCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。