VB.Net by API/System.Reflection/BindingFlags — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 16:40, 26 мая 2010
BindingFlags.Instance
Option Strict On
Imports System.IO
Imports System.Reflection
Public Module Reflection
Public Sub Main
Const path As String = "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll"
If File.Exists(path) Then
Dim ass As Assembly = Assembly.LoadFrom(path)
Dim typ As Type = ass.GetType("System.Array")
Dim members As MemberInfo() = typ.GetMembers(BindingFlags.Instance _
Or BindingFlags.Public)
Console.WriteLine(members.Length)
End If
End Sub
End Module
BindingFlags.Static
Imports System
Imports System.Reflection
Public Class MainClass
Shared Sub Main( )
Dim t As Type = Type.GetType("System.Reflection.Assembly")
Dim mbrInfoArray As MemberInfo( ) = t.FindMembers( _
MemberTypes.Method, _
BindingFlags.Public Or _
BindingFlags.Static Or _
BindingFlags.NonPublic Or _
BindingFlags.Instance Or _
BindingFlags.DeclaredOnly, _
Type.FilterName, "Get*")
Dim inf As MemberInfo
For Each inf In mbrInfoArray
Console.WriteLine("{0} is a {1}", _
inf, inf.MemberType)
Next
End Sub
End Class