Friday, June 7, 2013

Reflection



Reflection contd.......


1. Reflection Provides a classes or Attributes for

1. Writing the Information to metadata.
Reason for Writing the information to Metadata.

1) To Solve the Dll-Hell(P)
assembly:AssemblyVersion(1.0.0.0)

2. To Create Shared Assembly
sn-k,assembly:AssemblyKeyFile("")
3. For Deployment of any given assembly,we need to provide
appropriate information
assembly:AssemblyDescription("")
assembly:AssemblyTrademark("")

2. Reading the Information from metadata.

Reason for Reading the information from Metadata.

1. We need to Find the type of an Assembly.

2. to Find the namespace name and its classes.

3. we must know the type of function or class(virtual,static,sealed,abstract)

** 4.By Reflection we can also access the base class information.

Sometimes he wants to check ur coding part:
1. Versioning
2. Shared Assembly
3. Type of an Assembly

4. Namespace information.
5. class and its base class and its related function.
using System; 
using System.Reflection; 

class vinod { 
static void Main(string[] args) {
Assembly ptr = Assembly.LoadFrom("d:\\kuldeep\\it.dll");
Type[] t = ptr.GetTypes(); 
foreach (Type t2 in t) { 
  if (t2.IsClass) { 
     Console.WriteLine(t2.FullName); 
     List(t2); } } }
static void List(Type t3) {
  MethodInfo[] m = t3.GetMethods(); 
    foreach (MethodInfo m2 in m) { 
         Console.WriteLine(m2.Name); }
}
}//End of Class

No comments:

Post a Comment