public void SetAV(string av, object value, bool?propagate) { if (av.Contains(".")) { string firstPart = av.Substring(0, av.IndexOf('.')); string secondPart = av.Substring(av.IndexOf('.') + 1); if (firstPart == "BaseStats") { BaseStats.SetStat(secondPart, value); if (!propagate.HasValue) { UpdateStats(); } } else if (firstPart == "DerivedStats") { DerivedStats.SetStat(secondPart, value); } else if (firstPart == "Conditions") { string fqConditionName = GetType().Namespace + "." + value.ToString(); Condition c = (Condition)Activator.CreateInstance(Type.GetType(fqConditionName)); Conditions.Add(c); if (!propagate.HasValue) { UpdateStats(); } } else if (firstPart == "ExtraData") { ExtraData[secondPart] = value; } } else { //search and set property var prop = GetType().GetProperty(av); prop.SetValue(this, Convert.ChangeType(value, prop.PropertyType), null); } if (propagate.HasValue && propagate.Value) { UpdateStats(); } }