private bool SetReflectionField(string FieldName, object Value) { EHomuBehavior homBehav; EHomuSkillUsage homSkill; Type reflectionObject = this.GetType(); FieldInfo field = reflectionObject.GetField(FieldName); if (field == null) { return(false); } if (field.FieldType == typeof(int)) { field.SetValue(this, int.Parse((string)Value)); } else if (field.FieldType == typeof(bool)) { field.SetValue(this, (Value.ToString() == "1" || Value.ToString().ToLower() == "true" ? true : false)); } else if (EHomuBehaviorExtension.FromConfig((string)Value, out homBehav)) { field.SetValue(this, homBehav); } else if (EHomuSkillUsageExtension.FromConfig((string)Value, out homSkill)) { field.SetValue(this, homSkill); } else { MessageBox.Show("Unbekannter FeldTyp von \"" + FieldName + "\": " + field.FieldType.Name, "Config Fehler", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(true); }
public bool AddTact(int ID, string Name, string Behav, string Skill, int Priority) { EHomuBehavior homBehav; EHomuSkillUsage homSkill; if (EHomuBehaviorExtension.FromConfig(Behav, out homBehav) == false) { return(false); } if (EHomuSkillUsageExtension.FromConfig(Skill, out homSkill) == false) { return(false); } return(AddTact(ID, Name, homBehav, homSkill, Priority)); }