private void InitEvent() { _defaultBind = BindTool.GetDefaultBind(_component); if (_propChangeCb == null) { _propChangeCb = (_defaultBind as IFieldChangeCb <TData>)?.GetFieldChangeCb(); } if (_componentEvent == null) { _componentEvent = (_defaultBind as IComponentEvent <TData>)?.GetComponentEvent(); } switch (_bindType) { case BindType.OnWay: Log.Assert(_propChangeCb != null); _property.AddListener((value) => _propChangeCb(_prop2CpntWrap == null ? value : _prop2CpntWrap(value))); break; case BindType.Revert: Log.Assert(_componentEvent != null); _componentEvent.AddListener((data) => _property.Value = _cpnt2PropWrap == null ? data : _cpnt2PropWrap(data)); break; } }
private void InitEvent() { _defaultBind = BindTool.GetDefaultBind(_component); if (_componentEvent == null) { _componentEvent = (_defaultBind as IComponentEvent <TResult>)?.GetComponentEvent(); } if (_fieldChangeCb == null) { _fieldChangeCb = (_defaultBind as IFieldChangeCb <TResult>)?.GetFieldChangeCb(); } Log.Assert(_field2CpntConvert != null || _cpnt2FieldConvert != null); if (_field2CpntConvert != null) { _property.AddListener((value) => _fieldChangeCb(_field2CpntConvert(value))); } if (_cpnt2FieldConvert != null) { _componentEvent?.AddListener((val) => _property.Value = _cpnt2FieldConvert(val)); } }