2

I am using CefGlue to execute JavaScript code against a browser.

 if (browser.GetMainFrame().V8Context.TryEval(script, out returnValue, out ex)) {
       if (returnValue != null) {
            SetClientValuetFromV8Value(returnValue, result);
       }
 }

And that is the method responsible for maping the CefV8Value to .NET data types

   private static void SetClientValuetFromV8Value(CefV8Value returnValue, JSResult result) {
        if (returnValue == null) {
            throw new ArgumentNullException("returnValue");
        }

        if (result == null) {
            throw new ArgumentNullException("result");
        }

        object v = null;
        string type;
        if (returnValue.IsString) {
            v = returnValue.GetStringValue();
        }
        else if (returnValue.IsInt) {
            v = returnValue.GetIntValue();
        }
        else if (returnValue.IsBool) {
            v = returnValue.GetBoolValue();
        }
        else if (returnValue.IsDate) {
            v = returnValue.GetDateValue();
        }
        else if (returnValue.IsDouble) {
            v = returnValue.GetDoubleValue();
        }
        else if (returnValue.IsArray) {
            // what do we put in here??
        }
        else if (returnValue.IsObject) {
            // what do we put in here??
        }

        result.JsValue = new JSValue(v);
    }

It seems to me that there is no way to get the value when IsObject or IsArray return true. There is no method available for GetObjectValue() or GetArrayValues()

I know that I can make my javascript code convert everything to string before returning it but that is not what I need.

Mihail Shishkov
  • 14,129
  • 7
  • 48
  • 59

0 Answers0