private void InitEvent() { if (_componentEvent == null) { _componentEvent = (_component as IComponentEvent)?.GetComponentEvent(); } if (_componentEvent == null) { _defaultWrapper = BindTool.GetDefaultWrapper(_component); _componentEvent = (_defaultWrapper as IComponentEvent)?.GetComponentEvent(); } Log.Assert(_componentEvent != null); if (_componentEvent == null) { return; } if (_wrapFunc == null) { _componentEvent.AddListener(() => _command()); } else { _componentEvent.AddListener(() => _wrapFunc(_command)()); } }
private void InitEvent() { _defaultWrapper = BindTool.GetDefaultWrapper(_component); if (_propChangeCb == null) { _propChangeCb = (_defaultWrapper as IFieldChangeCb <TData>)?.GetFieldChangeCb(); } if (_componentEvent == null) { _componentEvent = (_defaultWrapper as IComponentEvent <TData>)?.GetComponentEvent(); } switch (_bindType) { case BindType.OnWay: Log.Assert(_propChangeCb != null); if (_propChangeCb == null) { return; } _property.AddListener((value) => _propChangeCb(_prop2CpntWrap == null ? value : _prop2CpntWrap(value))); break; case BindType.Revert: Log.Assert(_componentEvent != null); if (_componentEvent == null) { return; } _componentEvent.AddListener((data) => _property.Value = _cpnt2PropWrap == null ? data : _cpnt2PropWrap(data)); break; } }
private void InitEvent() { var bind = BindTool.GetDefaultWrapper(_component); _bindDic = _bindDic ?? _component as IBindDic ?? bind as IBindDic; Log.Assert(_bindDic != null); _dictionary.CollectionChanged += _bindDic.GetBindDicFunc(); }
private void InitEvent() { _defaultWrapper = BindTool.GetDefaultWrapper(Container, _component); _componentEvent = _componentEvent ?? (_component as IComponentEvent)?.GetComponentEvent() ?? (_defaultWrapper as IComponentEvent)?.GetComponentEvent(); Debug.Assert(_componentEvent != null, "componentEvent can not be null"); // 清除一下上次的绑定 _componentEvent.RemoveListener(Listener); _componentEvent.AddListener(Listener); }
private void InitEvent() { _defaultWrapper = BindTool.GetDefaultWrapper(_component); _componentEvent = _componentEvent ?? (_defaultWrapper as IComponentEvent <TData>)?.GetComponentEvent(); Log.Assert(_componentEvent != null); if (_wrapFunc == null) { _componentEvent.AddListener((value) => _command(value)); } else { _componentEvent.AddListener((value) => _wrapFunc(_command)(value)); } }
private void InitEvent() { _defaultWrapper = BindTool.GetDefaultWrapper(_component); _componentEvent = _componentEvent ?? (_component as IComponentEvent <TResult>)?.GetComponentEvent() ?? (_defaultWrapper as IComponentEvent <TResult>)?.GetComponentEvent(); _propChangeCb = _propChangeCb ?? (_component as IFieldChangeCb <TResult>)?.GetFieldChangeCb() ?? (_defaultWrapper as IFieldChangeCb <TResult>)?.GetFieldChangeCb(); Log.Assert(_prop2CpntWrap != null || _cpnt2PropWrap != null); if (_prop2CpntWrap != null) { _property.AddListener((value) => _propChangeCb(_prop2CpntWrap(value))); } if (_cpnt2PropWrap != null) { _componentEvent.AddListener((val) => _property.Value = _cpnt2PropWrap(val)); } }
private void InitEvent() { _defaultWrapper = BindTool.GetDefaultWrapper(_component); _componentEvent = _componentEvent ?? (_component as IComponentEvent)?.GetComponentEvent() ?? (_defaultWrapper as IComponentEvent)?.GetComponentEvent(); Log.Assert(_componentEvent != null, "componentEvent can not be null"); if (_wrapFunc == null) { _componentEvent.AddListener(() => _command()); } else { _componentEvent.AddListener(() => _wrapFunc(_command)()); } }
private void InitEvent() { _defaultWrapper = BindTool.GetDefaultWrapper(Container, _component); _componentEvent = _componentEvent ?? (_component as IComponentEvent <TResult>)?.GetComponentEvent() ?? (_defaultWrapper as IComponentEvent <TResult>)?.GetComponentEvent(); _propChangeCb = _propChangeCb ?? (_component as IFieldChangeCb <TResult>)?.GetFieldChangeCb() ?? (_defaultWrapper as IFieldChangeCb <TResult>)?.GetFieldChangeCb(); Debug.Assert(_prop2CpntWrap != null || _cpnt2PropWrap != null, "至少有一个wrapper"); if (_prop2CpntWrap != null) { Debug.Assert(_propChangeCb != null, "_propChangeCb 不能为空"); _property.AddListener(PropertyListener); } if (_cpnt2PropWrap != null) { Debug.Assert(_componentEvent != null, "_componentEvent 不能为空"); _componentEvent.AddListener(ComponentListener); } }
private void InitEvent() { _defaultWrapper = BindTool.GetDefaultWrapper(Container, _component); if (_componentEvent == null) { IComponentEvent <TData> changeCb = _defaultWrapper as IComponentEvent <TData>; if (_component is IComponentEvent <TData> cb) { changeCb = cb; } _componentEvent = changeCb?.GetComponentEvent(); } Debug.Assert(_componentEvent != null, $" can not found wrapper , check if the folder(Runtime/UI/Wrap) has {typeof(TComponent).Name} wrapper or {typeof(TComponent).Name} implements IComponentEvent<{typeof(TData).Name}> interface"); // 清除一下上次的绑定 _componentEvent.RemoveListener(Listener); _componentEvent.AddListener(Listener); }
private void InitEvent() { if (_componentEvent == null) { _componentEvent = (_component as IComponentEvent)?.GetComponentEvent(); } if (_componentEvent == null) { _defaultBind = BindTool.GetDefaultBind(_component); _componentEvent = (_defaultBind as IComponentEvent)?.GetComponentEvent(); } if (_wrapFunc == null) { _componentEvent?.AddListener(() => _command()); } else { _componentEvent?.AddListener(() => _wrapFunc(_command)()); } }
private void InitEvent() { if (_propChangeCb == null || _componentEvent == null) { _defaultWrapper = BindTool.GetDefaultWrapper(Container, _component); } switch (_bindType) { case BindType.OnWay: if (_propChangeCb == null) { IFieldChangeCb <TData> changeCb = _defaultWrapper as IFieldChangeCb <TData>; if (_component is IFieldChangeCb <TData> cb) { changeCb = cb; } _propChangeCb = changeCb?.GetFieldChangeCb(); } Debug.Assert(_propChangeCb != null, $"_propChangeCb != null , can not found wrapper , check if the folder(Runtime/UI/Wrap) has {typeof(TComponent).Name} wrapper or {typeof(TComponent).Name} implements IFieldChangeCb<{typeof(TData).Name}> interface"); _property.AddListener(PropertyListener); break; case BindType.Revert: if (_componentEvent == null) { IComponentEvent <TData> changeCb = _defaultWrapper as IComponentEvent <TData>; if (_component is IComponentEvent <TData> cb) { changeCb = cb; } _componentEvent = changeCb?.GetComponentEvent(); } Debug.Assert(_componentEvent != null, $" can not found wrapper , check if the folder(Runtime/UI/Wrap) has {typeof(TComponent).Name} wrapper or {typeof(TComponent).Name} implements IComponentEvent<{typeof(TData).Name}> interface"); _componentEvent.AddListener(ComponentListener); 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)); } }