Exemplo n.º 1
0
        public bool GetSimpleValue(IJavascriptObject decoratedValue, out object res, Type iTargetType = null)
        {
            res = null;
            var value = decoratedValue.Convert();

            if ((value.IsUndefined) || (value.IsNull))
            {
                return(true);
            }

            if (value.IsString)
            {
                res = value.StringValue;
                return(true);
            }

            if (value.IsBool)
            {
                res = value.BoolValue;
                return(true);
            }

            if (iTargetType.IsUnsigned())
            {
                if (value.IsUint)
                {
                    res = value.UintValue;
                }
            }
            else
            {
                if (value.IsInt)
                {
                    res = value.IntValue;
                }
            }

            if ((res == null) && (value.IsDouble))
            {
                res = value.DoubleValue;
            }

            if (res != null)
            {
                if (iTargetType != null)
                {
                    res = Convert.ChangeType(res, iTargetType);
                }

                return(true);
            }

            if (value.IsDate)
            {
                res = value.DateValue.ToUniversalTime(value.DateValue);
                return(true);
            }

            return(false);
        }
        public bool GetSimpleValue(IJavascriptObject value, out object res, Type iTargetType = null)
        {
            var convert = value.Convert();

            res = GetSimpleValue(convert, iTargetType);
            return((res != null) || (IsObjectNullorUndefined(convert)));
        }
        public IJavascriptObject ExecuteFunction(IWebView webViewGeneric, IJavascriptObject context, params IJavascriptObject[] parameters)
        {
            var webView = webViewGeneric as AwesomiumWebView;

            if (webView == null)
            {
                return(null);
            }

            return(new JSValue_JavascriptObject(webView.ExecuteFunction(_JSValue, context.Convert(), parameters.Select(el => el.Convert()).ToArray())));
        }
        public bool GetSimpleValue(IJavascriptObject decoratedValue, out object res, Type iTargetType = null) 
        {
            res = null;
            var value = decoratedValue.Convert();

            if ((value.IsUndefined) || (value.IsNull)) 
            {
                return true;
            }

            if (value.IsString) 
            {
                res = value.StringValue;
                return true;
            }

            if (value.IsBool) 
            {
                res = value.BoolValue;
                return true;
            }

            if (iTargetType.IsUnsigned()) 
            {
                if (value.IsUint)
                    res = value.UintValue;
            }
            else 
            {
                if (value.IsInt)
                    res = value.IntValue;
            }

            if ((res == null) && (value.IsDouble)) 
            {
                res = value.DoubleValue;
            }

            if (res != null) 
            {
                if (iTargetType != null)
                    res = Convert.ChangeType(res, iTargetType);

                return true;
            }

            if (value.IsDate) 
            {
                res = value.DateValue.ToUniversalTime(value.DateValue);
                return true;
            }

            return false;
        }
        public void ExecuteFunctionNoResult(IWebView webViewGeneric, IJavascriptObject context, params IJavascriptObject[] parameters)
        {
            var webView = webViewGeneric as AwesomiumWebView;

            if (webView == null)
            {
                return;
            }

            var realContext = (context != null) ? context.Convert() : (JSValue) new JSObject();

            webView.ExecuteFunction(_JSValue, realContext, parameters.Select(el => el.Convert()).ToArray());
        }
Exemplo n.º 6
0
        public IEnumerable <IJavascriptObject> CreateObjectsFromConstructor(int number, IJavascriptObject constructor, params IJavascriptObject[] parameters)
        {
            var builder = _ObjectWithConstructorBuilder.Value;

            for (var i = 0; i < number; i++)
            {
                var args = new List <CefV8Value>()
                {
                    CefV8Value.CreateInt((int)_Count++),
                    constructor.Convert()
                };
                var command = builder.ExecuteFunction(null, args.Concat(parameters.Select(p => p.Convert())).ToArray());
                yield return(UpdateObject(command));
            }
        }
Exemplo n.º 7
0
        public IEnumerable <IJavascriptObject> CreateObjectsFromContructor(int number, IJavascriptObject constructor, params IJavascriptObject[] parameters)
        {
            var args = new List <CfrV8Value> {
                CfrV8Value.CreateInt((int)_Count),
                CfrV8Value.CreateInt(number),
                constructor.Convert(),
                _ObjectCreationCallbackFunction.Value
            };

            args.AddRange(parameters.Convert());

            _ObjectWithConstructorBulkBuilder.Value.ExecuteFunction(null, args.ToArray());
            var results = _ObjectCallback.GetLastArguments();

            return(results.Select(result => result.ConvertObject(_Count++)));
        }
 public bool GetSimpleValue(IJavascriptObject value, out object res, Type iTargetType = null)
 {
     res = GetSimpleValue(value.Convert(), iTargetType);
     return res != null;
 }
 public void SetValue(int index, IJavascriptObject element)
 {
     _CfrV8Value.SetValue(index, element.Convert());
 }
 public void ExecuteFunctionNoResult(IWebView webView, IJavascriptObject context, params IJavascriptObject[] parameters)
 {
     _CfrV8Value.ExecuteFunction(context?.Convert(), parameters.Convert());
 }
 public IJavascriptObject ExecuteFunction(IWebView webView, IJavascriptObject context, params IJavascriptObject[] parameters)
 {
     return(_CfrV8Value.ExecuteFunction(context?.Convert(), parameters.Convert()).Convert());
 }
Exemplo n.º 12
0
 public void SetValue(int index, IJavascriptObject element)
 {
     _CfrV8Value.SetValue(index, element.Convert());
 }
Exemplo n.º 13
0
 public void SetValue(string attributeName, IJavascriptObject element, CreationOption ioption = CreationOption.None)
 {
     _CfrV8Value.SetValue(attributeName, element.Convert(), (CfxV8PropertyAttribute)ioption);
 }
 public void SetValue(string attributeName, IJavascriptObject element, CreationOption ioption = CreationOption.None) 
 {
     _CfrV8Value.SetValue(attributeName, element.Convert(), (CfxV8PropertyAttribute) ioption);
 }
Exemplo n.º 15
0
 public void SetValue(string AttributeName, IJavascriptObject element, CreationOption ioption = CreationOption.None)
 {
     ((JSObject)_JSValue)[AttributeName] = element.Convert();
 }
Exemplo n.º 16
0
 protected string GetStringAttribute(IJavascriptObject value, string attibutename)
 {
     return(_WebView.Evaluate(() => value.Convert().Invoke(attibutename, _WebView).GetStringValue()));
 }
Exemplo n.º 17
0
 public bool GetSimpleValue(IJavascriptObject value, out object res, Type iTargetType = null)
 {
     res = GetSimpleValue(value.Convert(), iTargetType);
     return(res != null);
 }
 public bool GetSimpleValue(IJavascriptObject value, out object res, Type iTargetType = null) 
 {
     var convert = value.Convert();
     res = GetSimpleValue(convert, iTargetType);
     return (res != null) || (IsObjectNullorUndefined(convert));
 }
 public void SetValue(int index, IJavascriptObject element)
 {
     ((JSValue[])_JSValue)[index] = element.Convert();
 }
 public void SetValue(string AttributeName, IJavascriptObject element, CreationOption ioption = CreationOption.None)
 {
     ((JSObject)_JSValue)[AttributeName] = element.Convert();
 }
 public void SetValue(int index, IJavascriptObject element)
 {
     ((JSValue[])_JSValue)[index] = element.Convert();
 }