Ejemplo n.º 1
0
        /// <summary>
        /// Converts a <see cref="JavaScriptValue"/> object into a host object.
        /// </summary>
        public object ToHostBoundObject(JavaScriptValue arg, Type toType)
        {
            var boundObject = _binder.ObjectLinkedTo(arg);

            if (null == boundObject)
            {
                // Object was constructed in JS and has no host object mapping, so we create one
                boundObject = NewHostObject(arg);
            }

            return(boundObject);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Attempts to get the <see cref="Type"/> bound to  the JS value as long as the JS value has
        /// a the value type of <see cref="JavaScriptValueType.Object"/>
        /// </summary>
        private static bool TryGetJsObjectType(JavaScriptValue value, JsBinder bindingData, out Type type)
        {
            if (!value.IsValid || value.ValueType != JavaScriptValueType.Object)
            {
                type = typeof(void);
                return(false);
            }

            var boundObject = bindingData.ObjectLinkedTo(value);

            if (null == boundObject)
            {
                type = typeof(void);
                return(false);
            }

            type = boundObject.GetType();
            return(true);
        }