Exemplo n.º 1
0
        internal JsValue KeepAliveDeleteProperty(int slot, string name)
        {
#if DEBUG_TRACE_API
            Console.WriteLine("deleting prop " + name);
#endif
            // TODO: This is pretty slow: use a cache of generated code to make it faster.
            var obj = KeepAliveGet(slot);
            if (obj != null)
            {
#if DEBUG_TRACE_API
                Console.WriteLine("deleting prop " + name + " type " + type);
#endif
                if (typeof(IDictionary).IsAssignableFrom(obj.GetType()))
                {
                    IDictionary dictionary = (IDictionary)obj;
                    if (dictionary.Contains(name))
                    {
                        dictionary.Remove(name);
                        return(_convert.ToJsValue(true));
                    }
                }
                return(_convert.ToJsValue(false));
            }
            return(JsValue.Error(KeepAliveAdd(new IndexOutOfRangeException("invalid keepalive slot: " + slot))));
        }
Exemplo n.º 2
0
        public void SetVariable(string name, object value)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            CheckDisposed();

            JsValue a = _convert.ToJsValue(value);

            jsengine_set_variable(_engine, name, a);
            jsvalue_dispose(a);

            // TODO: Check the result of the operation for errors.
        }
Exemplo n.º 3
0
        public void SetVariable(string name, object value)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }

            CheckDisposed();

            JsValue a = _convert.ToJsValue(value);
            JsValue b = jscontext_set_variable(_context, name, a);

#if DEBUG_TRACE_API
            Console.WriteLine("Cleaning up return value from set variable");
#endif
            jsvalue_dispose(a);
            jsvalue_dispose(b);
            // TODO: Check the result of the operation for errors.
        }