Bindingflags in .net
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
namespace BindingFlagsCS
{
class Program
{
static void Main(string[] args)
{
string path = @"C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.ServiceProcess.dll";
BindingFlags bf = BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance;
Assembly a = Assembly.LoadFrom(path);
Console.WriteLine(a.FullName);
Type[] types = a.GetTypes();
foreach (Type t in types)
{
Console.WriteLine("Type: {0}", t.Name);
MemberInfo[] mis = t.GetMembers(bf);
foreach (MemberInfo mi in mis)
{
Console.WriteLine("{0}: {1}", mi.MemberType, mi.Name);
}
}
Console.Read();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
namespace BindingFlagsCS
{
class Program
{
static void Main(string[] args)
{
string path = @"C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.ServiceProcess.dll";
BindingFlags bf = BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance;
Assembly a = Assembly.LoadFrom(path);
Console.WriteLine(a.FullName);
Type[] types = a.GetTypes();
foreach (Type t in types)
{
Console.WriteLine("Type: {0}", t.Name);
MemberInfo[] mis = t.GetMembers(bf);
foreach (MemberInfo mi in mis)
{
Console.WriteLine("{0}: {1}", mi.MemberType, mi.Name);
}
}
Console.Read();
}
}
}
VB.Net:
Imports System.Reflection
Module Module1
Sub Main()
Dim path As String = "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.ServiceProcess.dll"
Dim bf As BindingFlags = BindingFlags.DeclaredOnly Or BindingFlags.Public Or BindingFlags.Instance
Dim a As Assembly = Assembly.LoadFrom(path)
Console.WriteLine(a.FullName)
Dim types As Type() = a.GetTypes
For Each t As Type In types
Console.WriteLine("Type: {0}", t.Name)
Dim mis As MemberInfo() = t.GetMembers(bf)
For Each mi As MemberInfo In mis
Console.WriteLine("{0}: {1}", mi.MemberType, mi.Name)
Next
Next
Console.Read()
End Sub
End Module
Module Module1
Sub Main()
Dim path As String = "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.ServiceProcess.dll"
Dim bf As BindingFlags = BindingFlags.DeclaredOnly Or BindingFlags.Public Or BindingFlags.Instance
Dim a As Assembly = Assembly.LoadFrom(path)
Console.WriteLine(a.FullName)
Dim types As Type() = a.GetTypes
For Each t As Type In types
Console.WriteLine("Type: {0}", t.Name)
Dim mis As MemberInfo() = t.GetMembers(bf)
For Each mi As MemberInfo In mis
Console.WriteLine("{0}: {1}", mi.MemberType, mi.Name)
Next
Next
Console.Read()
End Sub
End Module