Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
    public static object CreateNewObject(ELEMENT e, object[] args, xmlScriptObj scrObj, STACKVAL stack)
    {
        ELEMENT last       = e.GetPointerLast();
        string  pointerstr = e.GetPointerString();
        string  name       = string.IsNullOrEmpty(pointerstr) ? last.raw : pointerstr + "." + last.raw;
        object  o          = null;

        var t = GetTypeOf(name);

        if (hglEtc.check_head(t.ToString(), "xmlScriptJS."))
        {
            if (args != null)
            {
                var jsargs = new xmlScriptJS.ARGS();
                jsargs.m_args = args;
                o             = System.Activator.CreateInstance(t, jsargs);
            }
            else
            {
                o = System.Activator.CreateInstance(t);
            }

            return(o);
        }

        var nargs = xmlScriptGetMethod.CreateArgsForCreateInstance(t, args);

        o = System.Activator.CreateInstance(t, nargs);

        return(o);
    }
Ejemplo n.º 5
0
        public string Join(ARGS arg)
        {
            string cchar = null;

            if (arg == null || arg.m_args == null || arg.m_args.Length == 0)
            {
                cchar = "";
            }

            if (cchar == null)
            {
                if (arg.m_args[0].GetType() == typeof(string))
                {
                    cchar = (string)arg.m_args[0];
                }
            }
            else
            {
                cchar = "";
            }

            string s = "";

            var keys = new List <object>(); foreach (var k in m_hash.Keys)

            {
                keys.Add(k);
            }

            for (int i = 0; i < keys.Count; i++)
            {
                if (i != 0)
                {
                    s += cchar;
                }
                s += m_hash[keys[i]];
            }

            return(s);
        }
Ejemplo n.º 6
0
        public Array(ARGS arg)
        {
            //m_mode = Mode.NONE;
            m_hash = new Hashtable();

            if (arg != null && arg.m_args.Length == 1 && arg.m_args[0].GetType() == typeof(int))
            {
                for (int i = 0; i < (int)arg.m_args[0]; i++)
                {
                    Set(i, new object());
                }
            }

            if (arg != null && arg.m_args.Length > 0)
            {
                for (int i = 0; i < arg.m_args.Length; i++)
                {
                    Debug.Log("[" + i + "]=" + arg.m_args[i]);
                    Set(i, arg.m_args[i]);
                }
            }
        }