Beispiel #1
0
 //wrap不同类型单向绑定
 public void Bind <TComponent, TData, TResult>(TComponent component,
                                               ObservableProperty <TData> property, Func <TData, TResult> field2CpntConvert,
                                               Action <TResult> fieldChangeCb = null) where TComponent : class
 {
     CanClearListeners.TryAdd(property);
     var convertBindField = new ConvertBindField <TComponent, TData, TResult>(component, property, fieldChangeCb,
                                                                              field2CpntConvert, null, null);
 }
Beispiel #2
0
        //wrap不同类型单向绑定
        public void Bind <TComponent, TData, TResult>(TComponent component,
                                                      ObservableProperty <TData> property, Func <TData, TResult> field2CpntConvert,
                                                      Action <TResult> fieldChangeCb = null) where TComponent : class
        {
            var bind = new ConvertBindField <TComponent, TData, TResult>(component, property, fieldChangeCb,
                                                                         field2CpntConvert, null, null);

            Binds.Add(bind);
        }
Beispiel #3
0
        //wrap不同类型反向绑定
        public void RevertBind <TComponent, TData, TResult>(TComponent component,
                                                            ObservableProperty <TData> property,
                                                            Func <TResult, TData> cpnt2FieldConvert,
                                                            UnityEvent <TResult> componentEvent = null) where TComponent : class
        {
            var bind = new ConvertBindField <TComponent, TData, TResult>(component, property, null, null,
                                                                         cpnt2FieldConvert, componentEvent);

            Binds.Add(bind);
        }
Beispiel #4
0
        //wrap不同类型单向绑定
        public void Bind <TComponent, TData, TResult>(TComponent component,
                                                      ObservableProperty <TData> property, Func <TData, TResult> field2CpntConvert,
                                                      Action <TResult> fieldChangeCb = null) where TComponent : class
        {
            ConvertBindField <TComponent, TData, TResult> bind;

            if (CacheBinds.Count > 0)
            {
                bind = (ConvertBindField <TComponent, TData, TResult>)CacheBinds.Dequeue();
            }
            else
            {
                bind = new ConvertBindField <TComponent, TData, TResult>(Container);
            }
            bind.Reset(component, property, fieldChangeCb, field2CpntConvert, null, null);
            AddClearable(bind);
        }
Beispiel #5
0
        //wrap不同类型反向绑定
        public void RevertBind <TComponent, TData, TResult>(TComponent component,
                                                            ObservableProperty <TData> property,
                                                            Func <TResult, TData> cpnt2FieldConvert,
                                                            UnityEvent <TResult> componentEvent = null) where TComponent : class
        {
            ConvertBindField <TComponent, TData, TResult> bind;

            if (CacheBinds.Count > 0)
            {
                bind = (ConvertBindField <TComponent, TData, TResult>)CacheBinds.Dequeue();
            }
            else
            {
                bind = new ConvertBindField <TComponent, TData, TResult>(Container);
            }
            bind.Reset(component, property, null, null, cpnt2FieldConvert, componentEvent);
            AddClearable(bind);
        }
Beispiel #6
0
 //wrap不同类型反向绑定
 public void RevertBind <TComponent, TData, TResult>(TComponent component,
                                                     ObservableProperty <TData> property,
                                                     Func <TResult, TData> cpnt2FieldConvert,
                                                     UnityEvent <TResult> componentEvent = null) where TComponent : class
 {
     Index++;
     CanClearListeners.TryAdd(property);
     if (!TryGetBinder <ConvertBindField <TComponent, TData, TResult> >(out var result,
                                                                        (bind) =>
     {
         bind.UpdateValue(component, property, null, null, cpnt2FieldConvert,
                          componentEvent);
     }))
     {
         result = new ConvertBindField <TComponent, TData, TResult>(component, property, null, null,
                                                                    cpnt2FieldConvert,
                                                                    componentEvent);
         CacheBinder[Index] = result;
     }
 }