예제 #1
0
        private static void SetNewValueOnBindedProp(object propInstance, BindableTarget bindableTarget)
        {
            if (bindableTarget.Converter != null && propInstance != null)
            {
                propInstance = bindableTarget.Converter(propInstance);
            }

            bindableTarget.Target.ProperyInstance = propInstance;
        }
예제 #2
0
        public Binder <TInstance, TProperty> BindToMethod <TTarget>(TTarget target, Action <TTarget, TProperty> method)
            where TTarget : class
        {
            var bindTarget = new BindableTarget
            {
                Target = new BindableMethod <TTarget, TProperty>(target, method)
            };

            _binds.Add(bindTarget);


            SetNewValueOnBindedProp(_source.ProperyInstance, bindTarget);

            return(this);
        }
예제 #3
0
        public Binder <TInstance, TProperty> BindTo <TTarget, TTargetProp>(TTarget target, Expression <Func <TTarget, TTargetProp> > targetProp, Func <TProperty, TTargetProp> converter)
            where TTarget : class
        {
            var bindTarget = new BindableTarget
            {
                Target = new Bindable <TTarget, TTargetProp>(target, targetProp),
            };

            if (converter != null)
            {
                bindTarget.Converter = (obj) => converter((TProperty)obj);
            }

            _binds.Add(bindTarget);


            SetNewValueOnBindedProp(_source.ProperyInstance, bindTarget);

            return(this);
        }