internal JavascriptSessionInjector(CefV8CompleteContext iWebView, IJSOBuilder iGlobalBuilder, IJavascriptListener iJavascriptListener)
        {
            _CefV8Context = iWebView;
            _GlobalBuilder = iGlobalBuilder;
            _IJavascriptListener = iJavascriptListener;


            if (_IJavascriptListener != null)
            {
                _Listener = _GlobalBuilder.CreateJSO();
                _Listener.Bind("TrackChanges",_CefV8Context, (c, o, e) => _IJavascriptListener.OnJavaScriptObjectChanges(e[0], e[1].GetStringValue(), e[2]));
                _Listener.Bind("TrackCollectionChanges", _CefV8Context, (c, o, e) => _IJavascriptListener.OnJavaScriptCollectionChanges(e[0], e[1].GetArrayElements(), e[2].GetArrayElements(), e[3].GetArrayElements()));
            }
            else
                _Listener = _GlobalBuilder.CreateJSO();
        }
        private CefV8Value GetMapper(IJavascriptMapper iMapperListener)
        {
            _IJavascriptMapper.Enqueue(iMapperListener);
    
            if (_Mapper != null)
                return _Mapper;

            _Mapper = _GlobalBuilder.CreateJSO();

            _Mapper.Bind("Register", _CefV8Context, (c, o, e) =>
            {
                if (_PullNextMapper)
                { 
                    _Current = _IJavascriptMapper.Dequeue();
                    _PullNextMapper = false;
                }

                if (_Current == null)
                    return;

                int count = e.Length;
                CefV8Value registered = e[0];

                switch (count)
                {
                    case 1:
                        _Current.RegisterFirst(registered);
                        break;

                    case 3:
                        _Current.RegisterMapping(e[1], e[2].GetStringValue(), registered);
                        break;

                    case 4:
                        _Current.RegisterCollectionMapping(e[1], e[2].GetStringValue(), e[3].GetIntValue(), registered);
                        break;
                }
             });

            _Mapper.Bind("End", _CefV8Context, (c, o, e) =>
                {
                    if (_PullNextMapper)
                        _Current = _IJavascriptMapper.Dequeue();

                    if (_Current!=null)
                        _Current.End(e[0]);
                    _Current = null;
                    _PullNextMapper = true;
                });

            return _Mapper;
        }
Example #3
0
 public void SetMappedJSValue(CefV8Value ijsobject, IJSCBridgeCache mapper)
 {
     _MappedJSValue = ijsobject;
     _MappedJSValue.Bind("Execute", _CefV8Context,(c, o, e) => Execute(e, mapper));
 }