コード例 #1
0
        public JsExternalObject CreateExternalObject(object obj)
        {
            //TODO: Set the Callback to a static method and remove it from the value.
            GCHandle objHandle = GCHandle.Alloc(obj);
            var      xoHandle  = m_engine.JsCreateExternalObject(GCHandle.ToIntPtr(objHandle), null);

            //this is a special case where we cannot use our CreateValue<> method.
            return(m_valuePool.GetOrAdd(xoHandle, () =>
            {
                var jsExternalObject = new JsExternalObject(m_engine, Context, xoHandle, objHandle);
                jsExternalObject.BeforeCollect += JsValueBeforeCollectCallback;
                return jsExternalObject;
            }) as JsExternalObject);
        }