public ReflectionDataObserver GetObserver(string key) { ReflectionDataObserver observer; if (!observers.TryGetValue(key, out observer)) { observer = new ReflectionDataObserver(key, type); observers.Add(key, observer); } return(observer); }
public void SetValue <T>(string key, T value, bool notify = false) { ReflectionDataObserver observer = GetObserver(key); if (observer.fieldInfo != null) { observer.fieldInfo.SetValue(this, value); if (notify) { observer.Invoke(this); } return; } if (observer.propertyInfo != null) { observer.propertyInfo.SetValue(this, value); if (notify) { observer.Invoke(this); } return; } }
public void AddObserver(string key, Action <DataComponent> onValueChanged) { ReflectionDataObserver observer = GetObserver(key); observer.AddEvent(onValueChanged); }