Esempio n. 1
0
        public Array concat(ARGS arg)
        {
            if (arg == null || arg.m_args == null || arg.m_args.Length == 0)
            {
                return(this);
            }

            int i = 0;

            Array newarray = new Array();

            foreach (var k in m_hash.Keys)
            {
                newarray.Set(i++, m_hash[k]);
            }

            foreach (var a in arg.m_args)
            {
                if (a.GetType() == typeof(Array))
                {
                    Hashtable h = (Hashtable)a;
                    foreach (var k in h.Keys)
                    {
                        newarray.Set(i++, h[k]);
                    }
                }
            }

            return(newarray);
        }
Esempio n. 2
0
        public Array splice(ARGS arg)
        {
            if (!arg.check(typeof(int), typeof(int), typeof(string)))
            {
                return(null);
            }
            int    start = (int)arg.Get(0);
            int    count = (int)arg.Get(1);
            string wd    = (string)arg.Get(2);

            var keyList = new List <object>(); foreach (var k in m_hash.Keys)
            {
                keyList.Add(k);
            }
            var valList = new List <object>(); foreach (var k in m_hash.Keys)
            {
                keyList.Add(m_hash[k]);
            }
            var newarray = new Array();

            for (int i = 0; i < keyList.Count; i++)
            {
                object o = valList[i];
                if (i >= start && i < start + count)
                {
                    o = wd;
                }
                newarray.Set(keyList[i], o);
            }

            return(newarray);
        }
Esempio n. 3
0
        public Array slice(ARGS arg)
        {
            if (!arg.check(typeof(int), typeof(int)))
            {
                return(null);
            }
            var start = (int)arg.Get(0);
            var end   = (int)arg.Get(1);

            var keyList = new List <object>(); foreach (var k in m_hash.Keys)
            {
                keyList.Add(k);
            }
            var valList = new List <object>(); foreach (var k in m_hash.Keys)
            {
                keyList.Add(m_hash[k]);
            }
            var newarray = new Array();

            for (int i = start; i < end; i++)
            {
                newarray.Set(keyList[i], valList[i]);
            }
            return(newarray);
        }
Esempio n. 4
0
    public static object CreateArray(ELEMENT e, xmlScriptObj scrObj, STACKVAL stack)
    {
        if (!e.isBLOCK_L())
        {
            return(null);
        }
        if (e.GetListCount() == 0)
        {
            return(null);
        }

        var array = new xmlScriptJS.Array();

        for (int i = 0; i < e.GetListCount(); i++)
        {
            array.Set(i, xmlScriptFunc.Execute(e.GetListElement(i), scrObj, stack));
        }
        return(array);
    }