/// <summary> /// 卸载任务的子任务 /// </summary> private void Disassemble(LogicTask task) { foreach (var item in task.GetType().GetProperties()) { if (item.PropertyType.IsSubclassOf(typeof(LogicTask))) { if (item.CanWrite) { LogicTask logic = (LogicTask)item.GetValue(task, null); task.Manager.Remove(logic); } } } }
private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { if (listBox1.SelectedIndex >= 0) { if (logicTask != null && logicTask.Name == Manager.FindTask(listBox1.SelectedItem.ToString()).Name) { return; } logicTask = Manager.FindTask(listBox1.SelectedItem.ToString()); checkBox1.Checked = logicTask.LoopTask; } if (logicTask != null) { comboBox1.Items.Clear(); propertyGrid1.SelectedObject = null; foreach (var item in logicTask.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)) { comboBox1.Items.Add(item.Name); comboBox1.SelectedIndex = 0; } } }