public void Test_List()
        {
            Test(() =>
            {
                var ibridgeresult = _ConverTOJSO.Map(_Tests).Result;
                ibridgeresult.Type.Should().Be(JsCsGlueType.Array);
                IJavascriptObject resv = ibridgeresult.JSValue;

                resv.Should().NotBeNull();
                resv.IsArray.Should().BeTrue();
                resv.GetArrayLength().Should().Be(2);

                IJavascriptObject res = resv.GetValue(0);
                res.Should().NotBeNull();
                var res1 = res.GetValue("S1");
                res1.Should().NotBeNull();
                res1.IsString.Should().BeTrue();

                var jsv = res.GetValue("S1");
                jsv.Should().NotBeNull();
                jsv.IsString.Should().BeTrue();
                string stv = jsv.GetStringValue();
                stv.Should().NotBeNull();
                stv.Should().Be("string1");

                var res2 = res.GetValue("I1");
                res2.Should().NotBeNull();
                res2.IsNumber.Should().BeTrue();
                int v2 = res2.GetIntValue();
                v2.Should().Be(1);
            });
        }
Esempio n. 2
0
 internal VueVmUpdater(IJavascriptObject helper)
 {
     ChangeAndInject = helper.GetValue("silentChangeAndInject");
     Change          = helper.GetValue("silentChange");
     AddProperty     = helper.GetValue("addProperty");
     InjectDetached  = helper.GetValue("injectDetached");
 }
Esempio n. 3
0
        internal BulkJsHelper(IJavascriptSessionCache cache, IWebView webView, IJavascriptObject helper)
        {
            _Cache   = cache;
            _WebView = webView;

            BulkCreator        = helper.GetValue("bulkCreate");
            CommandConstructor = helper.GetValue("Command");
            _CommandPrototype  = CommandConstructor.GetValue("prototype");
            _CommandPrototype.Bind("privateExecute", _WebView, ExecuteExecutable);
            _CommandPrototype.Bind("privateCanExecute", _WebView, CanExecuteCommand);

            ExecutableConstructor = helper.GetValue("Executable");
            _ExecutablePrototype  = ExecutableConstructor.GetValue("prototype");
            _ExecutablePrototype.Bind("privateExecute", _WebView, ExecuteExecutable);
        }
Esempio n. 4
0
        internal BulkJsHelper(ISessionCache cache, IWebView webView, IJavascriptObject helper)
        {
            _Cache = cache;

            BulkObjectsUpdater = helper.GetValue("bulkUpdateObjects");
            BulkArraysUpdater  = helper.GetValue("bulkUpdateArrays");
            CommandConstructor = helper.GetValue("Command");
            _CommandPrototype  = CommandConstructor.GetValue("prototype");
            _CommandPrototype.Bind("privateExecute", webView, ExecuteExecutable);
            _CommandPrototype.Bind("privateCanExecute", webView, CanExecuteCommand);

            ExecutableConstructor = helper.GetValue("Executable");
            _ExecutablePrototype  = ExecutableConstructor.GetValue("prototype");
            _ExecutablePrototype.Bind("privateExecute", webView, ExecuteExecutable);
        }
        public IGlueMapable GetGlueConvertible(IJavascriptObject javascriptObject, Type targetType)
        {
            if (javascriptObject == null)
            {
                return(new RawGlueMapable(null, null));
            }

            if (_JsUpdateHelper.GetSimpleValue(javascriptObject, out var targetValue, targetType))
            {
                return(new RawGlueMapable(targetValue, javascriptObject));
            }

            if (targetType?.IsEnum == true)
            {
                var intValue = javascriptObject.GetValue("intValue")?.GetIntValue();
                return(new RawGlueMapable(intValue.HasValue ? Enum.ToObject(targetType, intValue.Value) : null, javascriptObject));
            }

            var res = _SessionCache.GetCached(javascriptObject);

            if (res != null)
            {
                return(new SolvedGlueMapable(res));
            }

            var message = $"Unable to convert javascript object: {javascriptObject} to C# session. Value will be default to null. Please check javascript bindings.";

            _JsUpdateHelper.Logger.Info(message);
            throw new ArgumentException(message);
        }
Esempio n. 6
0
        private static void CheckDecimalCollection(IJavascriptObject coll, IList <decimal> skill)
        {
            coll.GetArrayLength().Should().Be(skill.Count);

            for (var i = 0; i < skill.Count; i++)
            {
                var c = (decimal)coll.GetValue(i).GetDoubleValue();
                c.Should().Be(skill[i]);
            }
        }
        private IJavascriptObject GetOrCreateSilenter(IJavascriptObject father)
        {
            var candidate = _Silenters.GetOrAddEntity(father, _ => father.GetValue("__silenter"));

            if (candidate.IsUndefined)
            {
                _Silenters.Remove(father);
            }
            return(candidate);
        }
Esempio n. 8
0
 internal MobxVmUpdater(IJavascriptObject helper)
 {
     AddProperty        = helper.GetValue("addProperty");
     SilentChange       = helper.GetValue("silentChange");
     SilentChangeUpdate = helper.GetValue("silentChangeUpdate");
     SilentSplice       = helper.GetValue("silentSplice");
     UpdateVm           = helper.GetValue("updateVm");
     UnListen           = helper.GetValue("unListen");
     ClearCollection    = helper.GetValue("clearCollection");
 }
        protected void Check(IJavascriptObject coll, IList<Skill> iskill) 
        {
            coll.GetArrayLength().Should().Be(iskill.Count);

            for (int i = 0; i < iskill.Count; i++) 
            {
                var c = coll.GetValue(i);

                (GetSafe(() => GetStringAttribute(c, "Name"))).Should().Be(iskill[i].Name);
                (GetSafe(() => GetStringAttribute(c, "Type"))).Should().Be(iskill[i].Type);
            }
        }
Esempio n. 10
0
        protected void CheckCollection(IJavascriptObject coll, IList <Skill> skill)
        {
            coll.GetArrayLength().Should().Be(skill.Count);

            for (var i = 0; i < skill.Count; i++)
            {
                var c = coll.GetValue(i);

                (GetSafe(() => GetStringAttribute(c, "Name"))).Should().Be(skill[i].Name);
                (GetSafe(() => GetStringAttribute(c, "Type"))).Should().Be(skill[i].Type);
            }
        }
        public async Task Test_List()
        {
            await TestAsync(async() =>
            {
                var ibridgeresult = await Map(_Tests);

                DoSafe(() =>
                {
                    ibridgeresult.Type.Should().Be(JsCsGlueType.Array);
                    IJavascriptObject resv = ibridgeresult.JSValue;

                    resv.Should().NotBeNull();
                    resv.IsArray.Should().BeTrue();
                    resv.GetArrayLength().Should().Be(2);

                    IJavascriptObject res = resv.GetValue(0);
                    res.Should().NotBeNull();
                    var res1 = res.GetValue("S1");
                    res1.Should().NotBeNull();
                    res1.IsString.Should().BeTrue();

                    var jsv = res.GetValue("S1");
                    jsv.Should().NotBeNull();
                    jsv.IsString.Should().BeTrue();
                    string stv = jsv.GetStringValue();
                    stv.Should().NotBeNull();
                    stv.Should().Be("string1");

                    var res2 = res.GetValue("I1");
                    res2.Should().NotBeNull();
                    res2.IsNumber.Should().BeTrue();
                    int v2 = res2.GetIntValue();
                    v2.Should().Be(1);
                });
            });
        }
        private Task UnsafeRegister(IJavascriptObject ijvm)
        {
            var tcs = new TaskCompletionSource <object>();

            _Listener.Bind("fulfill", _WebView, _ =>
            {
                _Logger.Debug("Vue ready received");
                tcs.TrySetResult(null);
            });

            var vueHelper = _VueHelper.Value;

            vueHelper.GetValue("ready").Invoke("then", _WebView, _Listener.GetValue("fulfill"));
            vueHelper.Invoke("register", _WebView, ijvm, _Listener);
            return(tcs.Task);
        }
Esempio n. 13
0
        public Task RegisterMainViewModel(IJavascriptObject jsObject)
        {
            var tcs = new TaskCompletionSource <object>();

            _Listener.Bind("fulfill", _WebView, _ =>
            {
                _Logger.Debug("Vue ready received");
                tcs.TrySetResult(null);
            });

            var vueHelper = _VueHelper.Value;

            vueHelper.GetValue("ready").Invoke("then", _WebView, _Listener.GetValue("fulfill"));
            vueHelper.Invoke("register", _WebView, jsObject, _Listener);
            return(tcs.Task);
        }
Esempio n. 14
0
        public IJsCsGlue GetCachedOrCreateBasic(IJavascriptObject javascriptObject, Type targetType)
        {
            if (javascriptObject == null)
            {
                return(null);
            }

            object targetvalue;

            if (Context.WebView.Converter.GetSimpleValue(javascriptObject, out targetvalue, targetType))
            {
                return(new JsBasicObject(javascriptObject, targetvalue));
            }

            if (targetType?.IsEnum == true)
            {
                var intValue = javascriptObject.GetValue("intValue")?.GetIntValue();
                if (!intValue.HasValue)
                {
                    return(null);
                }

                targetvalue = Enum.ToObject(targetType, intValue.Value);
                return(new JsEnum(javascriptObject, (Enum)targetvalue));
            }

            var res = _SessionCache.GetCached(javascriptObject);

            if (res != null)
            {
                return(res);
            }

            var message = $"Unable to convert javascript object: {javascriptObject} to C# session. Value will be default to null. Please check javascript bindings.";

            _Logger.Info(message);
            throw new ArgumentException(message);
        }
Esempio n. 15
0
 private static bool GetReadOnly(IJavascriptObject javascriptObject)
 {
     return(javascriptObject.GetValue(NeutroniumConstants.ReadOnlyFlag).GetBoolValue());
 }
 public string GetStringAttribute(IJavascriptObject value, string attibutename)
 {
     return _WebView.Evaluate(() => value.GetValue(attibutename).GetStringValue());
 }
        private static void Checkstring(IJavascriptObject coll, IEnumerable <string> iskill)
        {
            var javaCollection = Enumerable.Range(0, coll.GetArrayLength()).Select(i => coll.GetValue(i).GetStringValue());

            javaCollection.Should().Equal(iskill);
        }
        private IJavascriptObject GetOrCreateSilenter(IJavascriptObject father, string propertyName)
        {
            var dic = _Silenters.FindOrCreateEntity(father, _ => new Dictionary <string, IJavascriptObject>());

            return(dic.FindOrCreateEntity(propertyName, name => father.GetValue(name)));
        }
Esempio n. 19
0
 public int GetIntAttribute(IJavascriptObject value, string attributeName)
 {
     return(_WebView.Evaluate(() => value.GetValue(attributeName).GetIntValue()));
 }
Esempio n. 20
0
 internal VueVmUpdater(IJavascriptObject helper)
 {
     ChangeAndInject = helper.GetValue("silentChangeAndInject");
     Change          = helper.GetValue("silentChange");
 }
Esempio n. 21
0
 public double GetDoubleAttribute(IJavascriptObject value, string attibutename)
 {
     return(_WebView.Evaluate(() => value.GetValue(attibutename).GetDoubleValue()));
 }
Esempio n. 22
0
 private static ObjectObservability GetReadOnly(IJavascriptObject javascriptObject)
 {
     return((ObjectObservability)javascriptObject.GetValue(NeutroniumConstants.ReadOnlyFlag).GetIntValue());
 }
 private IJavascriptObject GetOrCreateSilenter(IJavascriptObject father, string propertyName)
 {
     var dic = _Silenters.FindOrCreateEntity(father, _ => new Dictionary<string, IJavascriptObject>());
     return dic.FindOrCreateEntity(propertyName, name => father.GetValue(name));
 }
 public bool GetBoolAttribute(IJavascriptObject value, string attibutename)
 {
     return _WebView.Evaluate(() => value.GetValue(attibutename).GetBoolValue());
 }
 private IJavascriptObject GetOrCreateSilenter(IJavascriptObject father)
 {
     var candidate = _Silenters.FindOrCreateEntity(father, _ => father.GetValue("__silenter"));
     if (candidate.IsUndefined) {
         _Silenters.Remove(father);
     }
     return candidate;
 }
Esempio n. 26
0
 private static int GetId(IJavascriptObject javascriptObject)
 {
     return(javascriptObject.GetValue(NeutroniumConstants.ObjectId).GetIntValue());
 }
Esempio n. 27
0
 public Task <IJavascriptObject> GetAttributeAsync(IJavascriptObject value, string attributeName)
 {
     return(_WebView.EvaluateAsync(() => value.GetValue(attributeName)));
 }
 public double GetDoubleAttribute(IJavascriptObject value, string attibutename)
 {
     return _WebView.Evaluate(() => value.GetValue(attibutename).GetDoubleValue());
 }
Esempio n. 29
0
        private static void CheckIntCollection(IJavascriptObject actual, IEnumerable <int> expected)
        {
            var javaCollection = Enumerable.Range(0, actual.GetArrayLength()).Select(i => actual.GetValue(i).GetIntValue());

            javaCollection.Should().Equal(expected);
        }
Esempio n. 30
0
 public string GetStringAttribute(IJavascriptObject value, string attibutename)
 {
     return(_WebView.Evaluate(() => value.GetValue(attibutename).GetStringValue()));
 }
Esempio n. 31
0
 public bool GetBoolAttribute(IJavascriptObject value, string attributeName)
 {
     return(_WebView.Evaluate(() => value.GetValue(attributeName).GetBoolValue()));
 }