public void OnSrcUpdated() { try { if (_converters != null && _converters.Length > 0) { DstTarget.SetValue(_converters.ChainConvert(SrcTarget.GetValue(), DstTarget.property.PropertyType, null)); } else if (SrcTarget.property.PropertyType == DstTarget.property.PropertyType) { DstTarget.SetValue(SrcTarget.GetValue()); } else if (SrcTarget.GetValue() is IConvertible) { DstTarget.SetValue(Convert.ChangeType(SrcTarget.GetValue(), DstTarget.property.PropertyType)); } else { DstTarget.SetValue(SrcTarget.GetValue()); } } catch (Exception e) { Debug.LogError($"Data binding error in: {OwnerObject.name}: {e}", OwnerObject); if (e.InnerException != null) { Debug.LogErrorFormat("Inner Exception: {0}", e.InnerException); } } }
public void DstUpdated() { if (_converters != null && _converters.Length > 0) { SrcTarget.SetValue(_converters.ChainConvertBack(DstTarget.GetValue(), SrcTarget.property.PropertyType, null)); } else if (SrcTarget.property.PropertyType == DstTarget.property.PropertyType) { SrcTarget.SetValue(DstTarget.GetValue()); } else { SrcTarget.SetValue(Convert.ChangeType(DstTarget.GetValue(), SrcTarget.property.PropertyType)); } }
internal void Bind() { if (IsBound) { return; } if (SrcTarget.IsReactive) { // var methodInfo = SrcTarget.propertyOwner.GetType().GetMethod("NonGenericSubscribe",BindingFlags.NonPublic|BindingFlags.Instance); // _subscription = (IDisposable) methodInfo.Invoke(SrcTarget.propertyOwner, // new[] // { // new Action<object>(o => PropertyChangedHandler(SrcTarget.propertyOwner, // new PropertyChangedEventArgs(SrcTarget.propertyName))) // }); _subscription = SrcTarget.ReactiveBind(PropertyChangedHandler); } // else // (SrcTarget.propertyOwner as INotifyPropertyChanged).PropertyChanged += PropertyChangedHandler; IsBound = true; }