usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Reflection;namespaceReflection_Test
{public classDLLAnalyst
{private stringfileName;public stringFileName
{get { returnfileName; }set{
fileName=value;this.myAssembly = Assembly.LoadFile(this.fileName);
}
}private Assembly myAssembly = null;publicDLLAnalyst() { }public DLLAnalyst(stringfileName)
{this.fileName =fileName;this.myAssembly = Assembly.LoadFile(this.fileName);
}public ListGetNameSpaces()
{if (this.myAssembly == null) return null;
List list = new List();
Type[] types= this.myAssembly.GetTypes();foreach (Type type intypes)
{if (!list.Contains(type.Namespace))
{
list.Add(type.Namespace);
}
}returnlist;
}public ListGetClasses()
{if (string.IsNullOrEmpty(this.fileName)) return null;
List list = new List();
Type[] types= this.myAssembly.GetTypes();foreach (Type type intypes)
{
ClassInfo classInfo= newClassInfo();
classInfo.NameSpace=type.Namespace;
classInfo.Name=type.Name;
classInfo.FullName=type.FullName;
classInfo.Type=type;
list.Add(classInfo);
}returnlist;
}//public List GetMethodByClass(ClassInfo classInfo)//{//if (this.myAssembly == null) return null;//MethodInfo[] methods = classInfo.Type.GetMethods();//List list = new List();//list.AddRange(methods);//return list;//}
}public classClassInfo
{private stringnameSpace;public stringNameSpace
{get { returnnameSpace; }set { nameSpace =value; }
}private stringname;public stringName
{get { returnname; }set { name =value; }
}private stringfullName;public stringFullName
{get { returnfullName; }set { fullName =value; }
}privateType type;publicType Type
{get { returntype; }set { type =value; }
}publicClassInfo() { }public ClassInfo(string nameSpace, string name,stringfullName,Type type)
{this.nameSpace =nameSpace;this.name =name;this.fullName =fullName;this.type =type;
}
}
}