コード例 #1
0
        public void IndexerOverride()
        {
            Jsni.reference("window").memberset("IndexerOverride", Jsni.@object(new
            {
                items = Jsni.array(),
                item  = Jsni.function((index, value) =>
                {
                    if (Jsni.arguments().As <JsArray>().length == 1)
                    {
                        return(Jsni.@this().member("items").As <JsArray>()[index]);
                    }
                    else
                    {
                        Jsni.@this().member("items").As <JsArray>()[index] = value;
                        return(null);
                    }
                })
            }));
            var indexerOverride = Jsni.reference("window").member("IndexerOverride").As <IndexerOverrideClass>();

            indexerOverride[3] = "foo";
            QUnit.AreEqual(indexerOverride[3], "foo");
        }
コード例 #2
0
        private static void GetBrowserInfo(this Window window)
        {
            if (browserProduct != null)
            {
                return;
            }

            var userAgent = window.Navigator.UserAgent;
            var match     = userAgent.match(Jsni.regex(@"(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*([\d\.]+)", "i")) ?? Jsni.array();

            if (Jsni.regex("trident", "i").test(match[1].As <JsString>()))
            {
                browserProduct = "MSIE";
                browserVersion = (Jsni.regex(@"\brv[ :]+(\d+(\.\d+)?)", "g").exec(userAgent) ?? new string[0])[1] ?? "";
                return;
            }
            if (match[2])
            {
                browserProduct = match[1].As <JsString>();
                browserVersion = match[2].As <JsString>();
            }
            else
            {
                browserProduct = window.Navigator.AppName;
                browserVersion = window.Navigator.AppVersion;
            }
            var tailVersion = userAgent.match(Jsni.regex(@"version\/([\.\d]+)", "i"));

            if (tailVersion != null)
            {
                browserVersion = tailVersion[1].As <JsString>();
            }
        }
コード例 #3
0
 public void ExportArray()
 {
     Jsni.reference("window").memberset("ExportTest", Jsni.@object(new { Values = Jsni.array() }));
     ExportTest.Values[0] = Tuple.Create("foo", 1);
     QUnit.IsTrue(ExportTest.Values is Tuple <string, int>[]);
 }