Exemplo n.º 1
0
        private void SetSourceValue <T>(IModifiable modifier, T value)
        {
            if (this.converter == null && typeof(T).Equals(this.sourceProxy.Type))
            {
                modifier.SetValue(value);
                return;
            }

            object safeValue = value;

            if (this.converter != null)
            {
                safeValue = this.converter.ConvertBack(safeValue);
            }

            safeValue = this.sourceProxy.Type.ToSafe(safeValue);

            modifier.SetValue(safeValue);
        }
        public virtual void SetValue <TValue>(TValue value)
        {
            IModifiable modifiable = this.GetModifiable();

            if (modifiable == null)
            {
                return;
            }

            modifiable.SetValue <TValue>(value);
        }
        public virtual void SetValue(object value)
        {
            IModifiable modifiable = this.GetModifiable();

            if (modifiable == null)
            {
                return;
            }

            modifiable.SetValue(value);
        }
Exemplo n.º 4
0
        protected void SetTargetValue <T>(IModifiable modifier, T value)
        {
            if (this.converter == null && typeof(T).Equals(this.targetProxy.Type))
            {
                modifier.SetValue(value);
                return;
            }

            object safeValue = value;

            if (this.converter != null)
            {
                safeValue = this.converter.Convert(value);
            }

            if (!typeof(UnityEventBase).IsAssignableFrom(this.targetProxy.Type))
            {
                safeValue = this.targetProxy.Type.ToSafe(safeValue);
            }

            modifier.SetValue(safeValue);
        }
Exemplo n.º 5
0
        protected void UpdateTargetFromSource(object value)
        {
            try
            {
                IModifiable modifier = this.targetProxy as IModifiable;
                if (modifier == null)
                {
                    return;
                }

                if (value == ReturnObject.NOTHING)
                {
                    return;
                }

                if (value == ReturnObject.UNSET)
                {
                    value = this.targetProxy.Type.CreateDefault();
                }
                else if (this.converter != null)
                {
                    value = this.converter.Convert(value);
                }

                if (!typeof(UnityEventBase).IsAssignableFrom(this.targetProxy.Type))
                {
                    value = this.targetProxy.Type.ToSafe(value);
                }

                Executors.RunOnMainThread(() => { modifier.SetValue(value); });
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.ErrorFormat("An exception occurs when the target property is updated.Please check this binding \"{0}\".exception: {1}", this.bindingDescription.ToString(), e);
                }
            }
        }
Exemplo n.º 6
0
        private void UpdateSourceFromTarget(object value)
        {
            try
            {
                IModifiable modifier = this.sourceProxy as IModifiable;
                if (modifier == null)
                {
                    return;
                }

                if (value == ReturnObject.NOTHING)
                {
                    return;
                }

                if (value == ReturnObject.UNSET)
                {
                    return;
                }

                if (this.converter != null)
                {
                    value = this.converter.ConvertBack(value);
                }

                value = this.sourceProxy.Type.ToSafe(value);

                modifier.SetValue(value);
            }
            catch (Exception e)
            {
                if (log.IsErrorEnabled)
                {
                    log.ErrorFormat("An exception occurs when the source property is updated.Please check this binding \"{0}\".exception: {1}", this.bindingDescription.ToString(), e);
                }
            }
        }