Пример #1
0
        protected override void Init()
        {
            _IJSOBuilder   = new CefV8_Factory(_WebView);
            _ICSharpMapper = Substitute.For <IJSCBridgeCache>();
            _ICSharpMapper.GetCached(Arg.Any <object>()).Returns((IJSCSGlue)null);
            _ConverTOJSO = new CSharpToJavascriptMapper(_WebView, new TestIUIDispatcher(), _ICSharpMapper);
            _Test        = new TestClass {
                S1 = "string", I1 = 25
            };
            _Tests = new List <TestClass>();
            _Tests.Add(new TestClass()
            {
                S1 = "string1", I1 = 1
            });
            _Tests.Add(new TestClass()
            {
                S1 = "string2", I1 = 2
            });
            _Test2 = new Test2()
            {
                T1 = _Test, T2 = _Test
            };

            _Tests_NG = new ArrayList();
            _Tests_NG.Add(_Tests[0]);
            _Tests_NG.Add(_Tests[0]);
        }
Пример #2
0
        public Test_ConvertToJSO()
        {
            _WebView       = WebCore.CreateWebView(500, 500, WebViewType.Offscreen);
            _IJSOBuilder   = new LocalBuilder(_WebView);
            _ICSharpMapper = Substitute.For <IJSCBridgeCache>();
            _ICSharpMapper.GetCached(Arg.Any <object>()).Returns((IJSCSGlue)null);
            _ConverTOJSO = new CSharpToJavascriptMapper(_IJSOBuilder, _ICSharpMapper);
            _Test        = new Test {
                S1 = "string", I1 = 25
            };
            _Tests = new List <Test>();
            _Tests.Add(new Test()
            {
                S1 = "string1", I1 = 1
            });
            _Tests.Add(new Test()
            {
                S1 = "string2", I1 = 2
            });
            _Test2 = new Test2()
            {
                T1 = _Test, T2 = _Test
            };

            _Tests_NG = new ArrayList();
            _Tests_NG.Add(_Tests[0]);
            _Tests_NG.Add(_Tests[0]);
        }
Пример #3
0
 private void Init()
 {
     _JavascriptToCSharpMapper = new JavascriptToCSharpMapper(_WebView);
     _IJSOBuilder   = new LocalBuilder(_WebView);
     _ICSharpMapper = Substitute.For <IJSCBridgeCache>();
     _ICSharpMapper.GetCached(Arg.Any <object>()).Returns((IJSCSGlue)null);
     _ConverTOJSO = new CSharpToJavascriptMapper(_IJSOBuilder, _ICSharpMapper);
 }
Пример #4
0
        protected override void Init()
        {
            _IJSOBuilder = new CefV8_Factory(_WebView);
            _ICSharpMapper = Substitute.For<IJSCBridgeCache>();
            _ICSharpMapper.GetCached(Arg.Any<object>()).Returns((IJSCSGlue)null);
            _ConverTOJSO = new CSharpToJavascriptMapper(_WebView, new TestIUIDispatcher(), _ICSharpMapper);
            _Test = new TestClass { S1 = "string", I1 = 25 };
            _Tests = new List<TestClass>();
            _Tests.Add(new TestClass() { S1 = "string1", I1 = 1 });
            _Tests.Add(new TestClass() { S1 = "string2", I1 = 2 });
            _Test2 = new Test2() { T1 = _Test, T2 = _Test };

            _Tests_NG = new ArrayList();
            _Tests_NG.Add(_Tests[0]);
            _Tests_NG.Add(_Tests[0]);
        }
        public Test_ConvertToJSO()
        { 
            _WebView = WebCore.CreateWebView(500, 500, WebViewType.Offscreen);
            _IJSOBuilder = new LocalBuilder(_WebView);
            _ICSharpMapper = Substitute.For<IJSCBridgeCache>();
            _ICSharpMapper.GetCached(Arg.Any<object>()).Returns((IJSCSGlue)null);
            _ConverTOJSO = new CSharpToJavascriptMapper(_IJSOBuilder, _ICSharpMapper);
            _Test = new Test { S1 = "string", I1 = 25 };
            _Tests = new List<Test>();
            _Tests.Add(new Test() { S1 = "string1", I1 = 1 });
            _Tests.Add(new Test() { S1 = "string2", I1 = 2 });
            _Test2 = new Test2() { T1 = _Test, T2 = _Test };

            _Tests_NG = new ArrayList();
            _Tests_NG.Add(_Tests[0]);
            _Tests_NG.Add(_Tests[0]);
        }
        private IJSCSGlue InternalMap(object ifrom, object iadditional = null)
        {
            if (ifrom == null)
            {
                return(JSGenericObject.CreateNull(_IWebView));
            }

            IJSCSGlue res = null;

            res = _Cacher.GetCached(ifrom);
            if (res != null)
            {
                return(res);
            }

            if (ifrom is ICommand)
            {
                return(new JSCommand(_IWebView, _UIDispatcher, ifrom as ICommand));
            }

            if (ifrom is ISimpleCommand)
            {
                return(new JSSimpleCommand(_IWebView, ifrom as ISimpleCommand));
            }

            if (ifrom is IResultCommand)
            {
                return(new JSResultCommand(_IWebView, ifrom as IResultCommand));
            }

            IJavascriptObject value;

            if (_IWebView.Factory.SolveBasic(ifrom, out value))
            {
                return(new JSBasicObject(value, ifrom));
            }

            if (ifrom.GetType().IsEnum)
            {
                var trueres = new JSBasicObject(_IWebView.Factory.CreateEnum((Enum)ifrom), ifrom);
                _Cacher.CacheLocal(ifrom, trueres);
                return(trueres);
            }

            IEnumerable ienfro = ifrom as IEnumerable;

            if ((ienfro != null) && Convert(ienfro, out res))
            {
                return(res);
            }

            IJavascriptObject resobject = _IWebView.Factory.CreateObject(true);

            JSGenericObject gres = new JSGenericObject(_IWebView, resobject, ifrom);

            _Cacher.Cache(ifrom, gres);

            MappNested(ifrom, resobject, gres);
            MappNested(iadditional, resobject, gres);

            return(gres);
        }
        internal IJSCSGlue Map(object ifrom, object iadditional = null)
        {
            if (ifrom == null)
            {
                return(new JSGenericObject(_IJSOBuilder.CreateNull(), ifrom));
            }

            IJSCSGlue res = null;

            res = _Cacher.GetCached(ifrom);
            if (res != null)
            {
                return(res);
            }

            if (ifrom is ICommand)
            {
                return(new JSCommand(_IJSOBuilder, ifrom as ICommand));
            }

            if (ifrom is ISimpleCommand)
            {
                return(new JSSimpleCommand(_IJSOBuilder, ifrom as ISimpleCommand));
            }

            if (ifrom is IResultCommand)
            {
                return(new JSResultCommand(_IJSOBuilder, ifrom as IResultCommand));
            }

            JSValue value;

            if (_Basic.Solve(ifrom, out value))
            {
                return(new JSBasicObject(value, ifrom));
            }

            if (ifrom.GetType().IsEnum)
            {
                var trueres = new JSBasicObject(_IJSOBuilder.CreateEnum((Enum)ifrom), ifrom);
                _Cacher.CacheLocal(ifrom, trueres);
                return(trueres);
            }

            IEnumerable ienfro = ifrom as IEnumerable;

            if ((ienfro != null) && Convert(ienfro, out res))
            {
                return(res);
            }

            JSObject resobject = _IJSOBuilder.CreateJSO();

            JSGenericObject gres = new JSGenericObject(new JSValue(resobject), ifrom);

            _Cacher.Cache(ifrom, gres);

            MappNested(ifrom, resobject, gres);
            MappNested(iadditional, resobject, gres);

            return(gres);
        }