Exemplo n.º 1
0
        internal static CefV8Value CastCefValueToCefV8Value(CefV8Context context, CefValue value, out bool isNew)
        {
            isNew = true;

            if (value is null)
            {
                return(CefV8Value.CreateNull());
            }

            if (!value.IsValid)
            {
                throw new InvalidCastException();
            }

            CefValueType valueType = value.Type;

            switch (valueType)
            {
            case CefValueType.String:
                return(new CefV8Value(value.GetString()));

            case CefValueType.Int:
                return(new CefV8Value(value.GetInt()));

            case CefValueType.Bool:
                return(new CefV8Value(value.GetBool()));

            case CefValueType.Null:
                return(CefV8Value.CreateNull());

            case CefValueType.Double:
                return(new CefV8Value(value.GetDouble()));

            case CefValueType.Binary:
                CefBinaryValue v = value.GetBinary();
                if (v.Size == 1)
                {
                    return(CefV8Value.CreateUndefined());
                }

                XrayHandle handle = XrayHandle.FromCfxBinaryValue(v);
                if (handle == XrayHandle.Zero)
                {
                    return(context.GetGlobal());
                }

                isNew = (handle.dataType != XrayDataType.Object && handle.dataType != XrayDataType.Function);
                return(handle.ToCefV8Value(context.Frame));
            }

            throw new NotSupportedException();
        }
Exemplo n.º 2
0
        public static long Get(CefV8Context context, XrayObject target, CefListValue args, out CefV8Value value)
        {
            CefV8Value   thisArg   = GetSafeThisArg(context, target);
            CefValue     arg3      = args.GetValue(3);
            CefValueType valueType = arg3.Type;

            if (valueType == CefValueType.Int)
            {
                value = thisArg.GetValueByIndex(arg3.GetInt());
                return(0);
            }

            string name = arg3.GetString();

            value = thisArg.GetValue(name);
            return(0);
        }