public void TestSciterValue() { //string[] arr = new string[] { "A", "B", "C" }; int[] arr = new int[] { 1, 2, 3 }; //SciterValue res = SciterValue.FromList(arr); SciterValue res = new SciterValue(); res.Append(new SciterValue(1)); res.Append(new SciterValue(1)); res.Append(new SciterValue(1)); string r = res.ToString(); string r2 = res.ToString(); string r3 = res.ToJSONString(SciterSharp.Interop.SciterXValue.VALUE_STRING_CVT_TYPE.CVT_JSON_LITERAL); { // http://sciter.com/forums/topic/erasing-sequence-elements-with-scitervalue/ SciterValue sv = SciterValue.FromJSONString("[1,2,3,4,5])"); sv[0] = SciterValue.Undefined; sv[2] = SciterValue.Undefined; SciterValue sv2 = SciterValue.FromJSONString("{one: 1, two: 2, three: 3}"); sv2["one"] = SciterValue.Undefined; } // Datetime { SciterValue sv = new SciterValue(DateTime.Now); } }
protected override bool OnScriptCall(SciterElement se, string name, SciterValue[] args, out SciterValue result) { result = null; switch (name) { case "Host_DownloadFont": string savefolder = args[0].Get(""); string family = args[1].Get(""); SciterValue async_cbk = args[2]; string str = async_cbk.ToString(); Task.Run(() => { bool res; try { GAPI.DownloadFont(family, savefolder); res = true; } catch (Exception) { res = false; } App.AppHost.InvokePost(() => { async_cbk.Call(new SciterValue(res)); }); }); return(true); } return(false); }
public void TestSciterValue() { //string[] arr = new string[] { "A", "B", "C" }; int[] arr = new int[] { 1, 2, 3 }; //SciterValue res = SciterValue.FromList(arr); SciterValue res = new SciterValue(); res.Append(new SciterValue(1)); res.Append(new SciterValue(1)); res.Append(new SciterValue(1)); string r = res.ToString(); string r2 = res.ToString(); string r3 = res.ToJSONString(SciterXValue.VALUE_STRING_CVT_TYPE.CVT_JSON_LITERAL); { // http://sciter.com/forums/topic/erasing-sequence-elements-with-scitervalue/ SciterValue sv = SciterValue.FromJSONString("[1,2,3,4,5])"); sv[0] = SciterValue.Undefined; sv[2] = SciterValue.Undefined; SciterValue sv2 = SciterValue.FromJSONString("{one: 1, two: 2, three: 3}"); sv2["one"] = SciterValue.Undefined; Assert.IsTrue(sv2["two"].Get(0) == 2); } // Datetime { var now = DateTime.Now; SciterValue sv = new SciterValue(now); Assert.IsTrue(sv.GetDate() == now); } // SciterValue.AsDictionary { SciterValue sv = SciterValue.FromJSONString("{ a: 1, b: true }"); var dic = sv.AsDictionary(); Assert.IsTrue(dic.Count == 2); } }