2using System.Collections.Generic;
3using System.ComponentModel;
8using System.Threading.Tasks;
9using System.Windows.Forms;
10using System.Reflection;
14 public partial class Library : Form
19 InitializeComponent();
29 private void importToolStripMenuItem_Click(
object sender, EventArgs e)
31 if (openFileDialog.ShowDialog() != DialogResult.OK)
33 dll =
new Lib(openFileDialog.FileName);
34 typeBox.Items.AddRange(
dll.
Types.Values.ToArray());
43 private void typeBox_SelectedIndexChanged(
object sender, EventArgs e)
45 Lib.TypeInfo item = (Lib.TypeInfo)typeBox.SelectedItem;
46 interBox.Items.Clear();
47 interBox.Items.AddRange(item.Interfaces.Values.ToArray());
48 methodsBox.Items.Clear();
49 foreach (List<MethodInfo> me
in item.Methods.Values)
51 foreach (MethodInfo meitem
in me)
53 methodsBox.Items.Add(meitem);
57 enumsBox.Items.Clear();
58 enumsBox.Items.AddRange(item.Enums.Values.ToArray());
64 public Dictionary<string, TypeInfo>
Types =
new Dictionary<string, TypeInfo>();
65 public Dictionary<string, TypeInfo>
Objects =
new Dictionary<string, TypeInfo>();
66 public Dictionary<string, Module>
Modules =
new Dictionary<string, Module>();
67 public Dictionary<string, ConstructorInfo>
Constructors =
new Dictionary<string, ConstructorInfo>();
68 public Dictionary<string, InterfaceMapping>
Interfaces =
new Dictionary<string, InterfaceMapping>();
82 public Dictionary<string, Enum>
Enums =
new Dictionary<string, Enum>();
83 public Dictionary<string, Type>
Interfaces =
new Dictionary<string, Type>();
84 public Dictionary<string, ConstructorInfo>
Constructors =
new Dictionary<string, ConstructorInfo>();
85 public Dictionary<string, List<MemberInfo>>
Members =
new Dictionary<string, List<MemberInfo>>();
86 public Dictionary<string, FieldInfo>
Fields =
new Dictionary<string, FieldInfo>();
87 public Dictionary<string, PropertyInfo> Properties =
new Dictionary<string, PropertyInfo>();
88 public Dictionary<string, List<MethodInfo>>
Methods =
new Dictionary<string, List<MethodInfo>>();
93 if(
Members.ContainsKey(inf.ToString()))
95 Members[inf.ToString()].Add(inf);
99 List<MemberInfo> l =
new List<MemberInfo>();
101 Members.Add(inf.ToString(), l);
106 if (
Methods.ContainsKey(inf.ToString()))
108 Methods[inf.ToString()].Add(inf);
112 List<MethodInfo> l =
new List<MethodInfo>();
114 Methods.Add(inf.ToString(), l);
119 Fields.Add(inf.ToString(),inf);
123 Properties.Add(inf.ToString(),inf);
125 public object Invoke(
string name,
object o,
object[] args)
127 return type.InvokeMember(name, BindingFlags.InvokeMethod,
null, o, args);
131 PropertyInfo p =
type.GetProperty(name);
132 return p.GetValue(obj);
136 return Activator.CreateInstance(
type);
153 dll = Assembly.LoadFile(file);
155 Type[] tps =
dll.GetExportedTypes();
156 foreach (Type type
in tps)
160 string s = type.ToString();
161 s = s.Remove(0, s.LastIndexOf(
'.') + 1);
174 Module[] mds =
dll.GetModules();
175 foreach (Module m
in mds)
177 string s = m.ToString();
178 s = s.Remove(0, s.LastIndexOf(
'.') + 1);
192 public object Invoke(Type type,
string name,
object o,
object[] args)
194 return type.InvokeMember(name, BindingFlags.InvokeMethod,
null, o, args);
206 public object Invoke(
string st,
string name,
object o,
object[] args)
208 Type t =
Types[st].type;
209 return t.InvokeMember(name, BindingFlags.InvokeMethod,
null, o, args);
220 Type myType =
Types[type].type;
221 PropertyInfo p = myType.GetProperty(name);
222 return p.GetValue(obj);
228 private void GetEnums(TypeInfo type)
230 Array ar = Enum.GetValues(type.type);
231 foreach (var item
in ar)
233 if(!type.Enums.ContainsKey(item.ToString()))
234 type.Enums.Add(item.ToString(), (Enum)item);
243 private void GetInterfaces(TypeInfo type)
245 Type[] ts = type.type.GetInterfaces();
246 foreach (Type item
in ts)
248 type.Interfaces.Add(item.ToString(), item);
254 private void GetConstructors(TypeInfo type)
256 ConstructorInfo[] ts = type.type.GetConstructors();
257 foreach (ConstructorInfo item
in ts)
259 type.Constructors.Add(item.ToString(), item);
265 private void GetMembers(TypeInfo type)
267 MemberInfo[] ts = type.type.GetMembers();
268 foreach (MemberInfo item
in ts)
270 type.AddMember(item);
276 private void GetProperties(TypeInfo type)
278 PropertyInfo[] ts = type.type.GetProperties();
279 foreach (PropertyInfo item
in ts)
281 type.AddProperty(item);
287 private void GetFields(TypeInfo type)
289 FieldInfo[] ts = type.type.GetFields();
290 foreach (FieldInfo item
in ts)
298 private void GetMethods(TypeInfo type)
300 MethodInfo[] ts = type.type.GetMethods();
301 foreach (MethodInfo item
in ts)
303 type.AddMethod(item);
Dictionary< string, Enum > Enums
Dictionary< string, Type > Interfaces
object Invoke(string name, object o, object[] args)
object GetProperty(string name, object obj)
void AddProperty(PropertyInfo inf)
Dictionary< string, List< MemberInfo > > Members
void AddMethod(MethodInfo inf)
Dictionary< string, List< MethodInfo > > Methods
override string ToString()
void AddField(FieldInfo inf)
void AddMember(MemberInfo inf)
Dictionary< string, FieldInfo > Fields
Dictionary< string, ConstructorInfo > Constructors
Dictionary< string, TypeInfo > Objects
Dictionary< string, Module > Modules
Dictionary< string, TypeInfo > Types
Dictionary< string, InterfaceMapping > Interfaces
Dictionary< string, ConstructorInfo > Constructors
object Invoke(Type type, string name, object o, object[] args)
object GetProperty(string type, string name, object obj)
object Invoke(string st, string name, object o, object[] args)