private void UpdateAssemblyTypes() { String assemblyName = tbExecuteAssembly.Text; if (!String.IsNullOrEmpty(assemblyName)) { var assembly = AssembliesHelper.GetAssemblyByName(assemblyName); var typez = assembly.GetTypes().Select(t => t.FullName).ToArray(); cbTypes.Items.Clear(); cbTypes.Items.AddRange(typez); } }
private void UpdateAssemblyTypeMethods() { var assemblyName = tbExecuteAssembly.Text; var typeName = cbTypes.SelectedItem as String; if (!String.IsNullOrEmpty(typeName) && !String.IsNullOrEmpty(assemblyName)) { var assembly = AssembliesHelper.GetAssemblyByName(assemblyName); var type = AssembliesHelper.GetTypeByName(assembly, typeName); var methods = type.GetMethods().Select(m => m.Name).ToArray(); cbMethods.Items.Clear(); cbMethods.Items.AddRange(methods); } }
private void Execute() { var assemblyName = tbExecuteAssembly.Text; var typeName = cbTypes.SelectedItem as String; var methodName = cbMethods.SelectedItem as String; if (!String.IsNullOrEmpty(typeName) && !String.IsNullOrEmpty(methodName)) { var assembly = AssembliesHelper.GetAssemblyByName(assemblyName); Type t = assembly.GetType(typeName); MethodInfo mi = t.GetMethod(methodName); object t_object = null; if (!mi.IsStatic) { t_object = assembly.CreateInstance(typeName); } System.Threading.Thread invokeThread; invokeThread = new System.Threading.Thread( new System.Threading.ThreadStart(() => { try { mi.Invoke(t_object, BindingFlags.Default | BindingFlags.Static | BindingFlags.InvokeMethod, null, null, CultureInfo.CurrentCulture); } catch (Exception e) { MessageBox.Show(String.Format("Error: {0}", e), "Error"); } }) ); invokeThread.Start(); } }