private IJavascriptObject GetMapper(IJavascriptMapper iMapperListener) { _IJavascriptMapper.Enqueue(iMapperListener); if (_Mapper != null) { return(_Mapper); } _Mapper = _IWebView.Factory.CreateObject(false); _Mapper.Bind("Register", _IWebView, (c, o, e) => { if (_PullNextMapper) { _Current = _IJavascriptMapper.Dequeue(); _PullNextMapper = false; } if (_Current == null) { return; } int count = e.Length; IJavascriptObject 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", _IWebView, (c, o, e) => { if (_PullNextMapper) { _Current = _IJavascriptMapper.Dequeue(); } if (_Current != null) { _Current.End(e[0]); } _Current = null; _PullNextMapper = true; }); return(_Mapper); }
private JSObject GetMapper(IJavascriptMapper iMapperListener) { _IJavascriptMapper.Enqueue(iMapperListener); if (_Mapper != null) { return(_Mapper); } _Mapper = _GlobalBuilder.CreateJSO(); _Mapper.Bind("Register", false, (o, e) => { if (_PullNextMapper) { _Current = _IJavascriptMapper.Dequeue(); _PullNextMapper = false; } if (_Current == null) { return; } int count = e.Arguments.Length; JSObject registered = (JSObject)e.Arguments[0]; switch (count) { case 1: _Current.RegisterFirst(registered); break; case 3: _Current.RegisterMapping((JSObject)e.Arguments[1], (string)e.Arguments[2], registered); break; case 4: _Current.RegisterCollectionMapping((JSObject)e.Arguments[1], (string)e.Arguments[2], (int)e.Arguments[3], registered); break; } }); _Mapper.Bind("End", false, (o, e) => { if (_PullNextMapper) { _Current = _IJavascriptMapper.Dequeue(); } if (_Current != null) { _Current.End((JSObject)e.Arguments[0]); } _Current = null; _PullNextMapper = true; }); return(_Mapper); }