Example #1
0
        public void Invoke(object value)
        {
            if (_runtimeCall == null)
            {
                _runtimeCall = GetRuntimeCall();
            }

            if (_runtimeCall != null)
            {
                switch (mode)
                {
                case PersistentListenerMode.Object:
                    /*if (!(value is float))
                     * {
                     *  return;
                     * }*/
                    break;

                case PersistentListenerMode.Float:
                    if (!(value is float))
                    {
                        value = Convert.ToDouble(value);
                    }
                    break;

                case PersistentListenerMode.Int:
                    if (!(value is int))
                    {
                        value = Convert.ToInt32(value);
                    }
                    break;

                case PersistentListenerMode.String:
                    if (!(value is string))
                    {
                        value = value.ToString();
                    }
                    break;

                case PersistentListenerMode.Bool:
                    if (value is string)
                    {
                        value = (value != "flase" && value != "0");
                    }
                    else
                    {
                        value = Convert.ToBoolean(value);
                    }
                    break;
                }
                _runtimeCall.Invoke(value);
            }
        }
Example #2
0
        public void Update()
        {
            if (!_dirty)
            {
                return;
            }
            _dirty = false;
            var args  = _expression.GetValue() as object[];
            var count = types.Length;

            for (var i = 0; i < count; ++i)
            {
                //if(args[i]==null)
                //args[i] =
                if (types[i] != args[i].GetType())
                {
                    args[i] = Convert.ChangeType(args[i], types[i]);
                }
            }
            _runtimeCall.Invoke(args);
        }