Exemple #1
0
 //单向绑定
 public void Bind <TComponent, TData>
     (TComponent component, ObservableProperty <TData> property, Action <TData> fileChangeCb = null,
     Func <TData, TData> prop2CpntWrap = null) where TComponent : class
 {
     CanClearListeners.TryAdd(property);
     var bindField = new BindField <TComponent, TData>(component, property, fileChangeCb, null, BindType.OnWay,
                                                       prop2CpntWrap, null);
 }
Exemple #2
0
        //单向绑定
        public void Bind <TComponent, TData>
            (TComponent component, ObservableProperty <TData> property, Action <TData> fieldChangeCb = null,
            Func <TData, TData> prop2CpntWrap = null) where TComponent : class
        {
            var bind = new BindField <TComponent, TData>(component, property, fieldChangeCb, null, BindType.OnWay,
                                                         prop2CpntWrap, null);

            Binds.Add(bind);
        }
Exemple #3
0
        //绑定两个field
        public void Bind <TComponent, TData1, TData2, TResult>
            (TComponent component, ObservableProperty <TData1> property1, ObservableProperty <TData2> property2,
            Func <TData1, TData2, TResult> wrapFunc, Action <TResult> filedChangeCb = null)
            where TComponent : class
        {
            var bind = new BindField <TComponent, TData1, TData2, TResult>(component, property1, property2,
                                                                           wrapFunc, filedChangeCb);

            Binds.Add(bind);
        }
Exemple #4
0
        //反向绑定
        public void RevertBind <TComponent, TData>
            (TComponent component, ObservableProperty <TData> property,
            UnityEvent <TData> componentEvent = null,
            Func <TData, TData> cpnt2PropWrap = null) where TComponent : class
        {
            var bind = new BindField <TComponent, TData>(component, property, null, componentEvent, BindType.Revert,
                                                         null, cpnt2PropWrap);

            Binds.Add(bind);
        }
Exemple #5
0
 //绑定两个field
 public void Bind <TComponent, TData1, TData2, TResult>
     (TComponent component, ObservableProperty <TData1> property1, ObservableProperty <TData2> property2,
     Func <TData1, TData2, TResult> wrapFunc, Action <TResult> filedChangeCb = null)
     where TComponent : class
 {
     CanClearListeners.TryAdd(property1);
     CanClearListeners.TryAdd(property2);
     var bindField = new BindField <TComponent, TData1, TData2, TResult>(component, property1, property2, wrapFunc,
                                                                         filedChangeCb);
 }
Exemple #6
0
        //反向绑定
        public void RevertBind <TComponent, TData>
            (TComponent component, ObservableProperty <TData> property,
            UnityEvent <TData> componentEvent = null,
            Func <TData, TData> cpnt2PropWrap = null) where TComponent : class
        {
            BindField <TComponent, TData> bind;

            if (CacheBinds.Count > 0)
            {
                bind = (BindField <TComponent, TData>)CacheBinds.Dequeue();
            }
            else
            {
                bind = new BindField <TComponent, TData>(Container);
            }
            bind.Reset(component, property, null, componentEvent, BindType.Revert, null, cpnt2PropWrap);
            AddClearable(bind);
        }
Exemple #7
0
        //单向绑定
        public void Bind <TComponent, TData>
            (TComponent component, ObservableProperty <TData> property, Action <TData> fieldChangeCb = null,
            Func <TData, TData> prop2CpntWrap = null) where TComponent : class
        {
            BindField <TComponent, TData> bind;

            if (CacheBinds.Count > 0)
            {
                bind = (BindField <TComponent, TData>)CacheBinds.Dequeue();
            }
            else
            {
                bind = new BindField <TComponent, TData>(Container);
            }

            bind.Reset(component, property, fieldChangeCb, null, BindType.OnWay, prop2CpntWrap, null);
            AddClearable(bind);
        }
Exemple #8
0
        //绑定两个field
        public void Bind <TComponent, TData1, TData2, TResult>
            (TComponent component, ObservableProperty <TData1> property1, ObservableProperty <TData2> property2,
            Func <TData1, TData2, TResult> wrapFunc, Action <TResult> filedChangeCb = null)
            where TComponent : class
        {
            BindField <TComponent, TData1, TData2, TResult> bind;

            if (CacheBinds.Count > 0)
            {
                bind = (BindField <TComponent, TData1, TData2, TResult>)CacheBinds.Dequeue();
            }
            else
            {
                bind = new BindField <TComponent, TData1, TData2, TResult>(Container);
            }
            bind.Reset(component, property1, property2, wrapFunc, filedChangeCb);
            AddClearable(bind);
        }
Exemple #9
0
 //反向绑定
 public void RevertBind <TComponent, TData>
     (TComponent component, ObservableProperty <TData> property,
     UnityEvent <TData> componentEvent = null,
     Func <TData, TData> cpnt2PropWrap = null) where TComponent : class
 {
     Index++;
     CanClearListeners.TryAdd(property);
     if (!TryGetBinder <BindField <TComponent, TData> >(out var result,
                                                        (bind) =>
     {
         bind.UpdateValue(component, property, null, componentEvent, BindType.Revert,
                          null, cpnt2PropWrap);
     }))
     {
         result = new BindField <TComponent, TData>(component, property, null, componentEvent, BindType.Revert,
                                                    null, cpnt2PropWrap);
         CacheBinder[Index] = result;
     }
 }