Exemplo n.º 1
0
            public SCRIPTING_METHOD_PARAMS_WRAPPER(SCRIPTING_METHOD_PARAMS prms)
            {
                name   = Marshal.PtrToStringAnsi(prms.name);
                args   = new SciterCore.SciterValue[prms.argc];
                result = SciterCore.SciterValue.Undefined;

                for (var i = 0; i < prms.argc; i++)
                {
                    var ptr = IntPtr.Add(prms.argv,
                                         i * Marshal.SizeOf(typeof(SciterValue.VALUE)));

                    args[i] = SciterCore.SciterValue.Attach(Marshal.PtrToStructure <SciterValue.VALUE>(ptr));
                }
            }
Exemplo n.º 2
0
        public void TestSciterValue()
        {
            //string[] arr = new string[] { "A", "B", "C" };
            int[] arr = new int[] { 1, 2, 3 };
            //SciterValue res = SciterValue.FromList(arr);
            SciterCore.SciterValue res = new SciterCore.SciterValue();
            res.Append(SciterValue.Create(1));
            res.Append(SciterValue.Create(1));
            res.Append(SciterValue.Create(1));
            res.Append(SciterValue.MakeSymbol("symbol").Append(SciterValue.Create(1)));
            string r  = res.ToString();
            string r2 = res.ToString();
            string r3 = res.AsJsonString(StringConversionType.JsonLiteral);

            {
                // http://sciter.com/forums/topic/erasing-sequence-elements-with-scitervalue/
                SciterCore.SciterValue sv = SciterCore.SciterValue.FromJsonString("[1,2,3,4,5])");
                sv[0] = SciterCore.SciterValue.Undefined;
                sv[2] = SciterCore.SciterValue.Undefined;

                SciterCore.SciterValue sv2 = SciterCore.SciterValue.FromJsonString("{one: 1, two: 2, three: 3}");
                sv2["one"] = SciterCore.SciterValue.Undefined;
                Assert.IsTrue(sv2["two"].AsInt32(0) == 2);
            }

            // Datetime
            {
                var         now = DateTime.Now;
                SciterValue sv  = SciterValue.Create(now);
                Assert.IsTrue(sv.AsDateTime(false) == now);
            }

            // SciterValue.AsDictionary
            {
                SciterCore.SciterValue sv = SciterCore.SciterValue.FromJsonString("{ a: 1, b: true }");
                var dic = sv.AsDictionary();
                Assert.IsTrue(dic.Count == 2);
            }
        }