Ejemplo n.º 1
0
        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;
            }
        }
Ejemplo n.º 2
0
 private void InitEvent()
 {
     _defaultBind = BindTool.GetDefaultBind(_component);
     if (_componentEvent == null)
     {
         _componentEvent = (_defaultBind as IComponentEvent <TData>)?.GetComponentEvent();
     }
     Log.Assert(_componentEvent != null);
     if (_wrapFunc == null)
     {
         _componentEvent.AddListener((value) => _command(value));
     }
     else
     {
         _componentEvent.AddListener((value) => _wrapFunc(_command)(value));
     }
 }
Ejemplo n.º 3
0
 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)());
     }
 }
Ejemplo n.º 4
0
 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));
     }
 }