Exemplo n.º 1
0
        public void OnSrcUpdated()
        {
            try
            {
                if (_converters != null && _converters.Length > 0)
                {
                    _dst.SetValue(_converters.ChainConvert(_src.GetValue(), _dst.property.PropertyType, null));
                }
                else if (_src.GetValue() is IConvertible)
                {
                    _dst.SetValue(Convert.ChangeType(_src.GetValue(), _dst.property.PropertyType));
                }
                else
                {
                    _dst.SetValue(_src.GetValue());
                }
            }
            catch (Exception e)
            {
                Debug.LogError("Data binding error in: " + _gameObject.name + ": " + e.Message);

                if (e.InnerException != null)
                {
                    Debug.LogErrorFormat("Inner Exception: {0}", e.InnerException.Message);
                }
            }
        }
Exemplo n.º 2
0
 public void DstUpdated()
 {
     if (_converter != null)
     {
         _src.SetValue(_converter.ConvertBack(_dst.GetValue(), _src.property.PropertyType, null));
     }
     else
     {
         _src.SetValue(Convert.ChangeType(_dst.GetValue(), _src.property.PropertyType));
     }
 }
Exemplo n.º 3
0
 public void DstUpdated()
 {
     if (_converters != null && _converters.Length > 0)
     {
         _src.SetValue(_converters.ChainConvertBack(_dst.GetValue(), _src.property.PropertyType, null));
     }
     else
     {
         _src.SetValue(Convert.ChangeType(_dst.GetValue(), _src.property.PropertyType));
     }
 }
Exemplo n.º 4
0
 public object this[int key]
 {
     get
     {
         var list = (src.GetValue() as IList);
         return(list[key]);
     }
     set
     {
         (src.GetValue() as IList)[key] = value;
     }
 }
Exemplo n.º 5
0
        public void SetProp()
        {
            try
            {
                var toSet = isProperty ? src.GetValue() : value;

                if (converter != null)
                {
                    dst.SetValue(converter.Convert(toSet, dst.property.PropertyType, null));
                }

                else if (dst.property.PropertyType.IsEnum)
                {
                    dst.SetValue(Enum.Parse(dst.property.PropertyType, toSet.ToString()));
                }
                else
                {
                    dst.SetValue(Convert.ChangeType(toSet, dst.property.PropertyType));
                }
            }
            catch (Exception exc)
            {
                Debug.LogErrorFormat("[EventPropertyBinding Error] - {0} Can't convert {1} to type {2}", gameObject.name, value, dst.property.PropertyType.Name);

                if (exc.InnerException != null)
                {
                    Debug.LogErrorFormat("Inner Exception: {0}", exc.InnerException.Message);
                }
            }
        }
Exemplo n.º 6
0
        public void DstUpdated()
        {
            try
            {
                _src.SetValue(_dst.GetValue(), _converter);
            }
            catch (Exception e)
            {
                Debug.LogError("Data binding error in: " + _gameObject.name);

                throw (e);
            }
        }
Exemplo n.º 7
0
        public void OnSrcUpdated()
        {
            try
            {
                if (_mode != BindingMode.OneWayToSource)
                {
                    _dst.SetValue(_src.GetValue(), _converter);
                }
            }
            catch (Exception e)
            {
                Debug.LogError("Data binding error in: " + _gameObject.name);

                throw (e);
            }
        }
Exemplo n.º 8
0
        public void OnSrcUpdated()
        {
            try
            {
                _dst.SetValue(_src.GetValue(), _converter);
            }
            catch (Exception e)
            {
                Debug.LogError("Data binding error in: " + _gameObject.name + ": " + e.Message);

                if (e.InnerException != null)
                {
                    Debug.LogErrorFormat("Inner Exception: {0}", e.InnerException.Message);
                }
            }
        }