Esempio n. 1
0
 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);
 }
Esempio n. 2
0
        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;
            }
        }