예제 #1
0
 static public int AddRange(IntPtr l)
 {
     try {
         IntList self = (IntList)checkSelf(l);
         System.Collections.Generic.IEnumerable <System.Int32> a1;
         checkType(l, 2, out a1);
         self.AddRange(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
예제 #2
0
        ///////////////////////////////////////////////////////////////////////////////////////////////

        public static ReturnCode SelectFromSubList(
            Interpreter interpreter,
            string text,
            string indexText,
            bool clear,
            CultureInfo cultureInfo,
            ref string value,
            ref IntList indexList,
            ref Result error
            )
        {
            ReturnCode code;

            if (!String.IsNullOrEmpty(indexText))
            {
                StringList indexTextList = null;

                code = Parser.SplitList(
                    interpreter, indexText, 0, Length.Invalid, true,
                    ref indexTextList, ref error);

                if (code == ReturnCode.Ok)
                {
                    if (indexTextList.Count > 0)
                    {
                        StringList list = null;

                        code = Parser.SplitList(
                            interpreter, text, 0, Length.Invalid, true,
                            ref list, ref error);

                        if (code == ReturnCode.Ok)
                        {
                            string  localValue     = null;
                            IntList localIndexList = new IntList();

                            for (int index = 0; index < indexTextList.Count; index++)
                            {
                                int listIndex = Index.Invalid;

                                code = Value.GetIndex(
                                    indexTextList[index], list.Count,
                                    ValueFlags.AnyIndex, cultureInfo,
                                    ref listIndex, ref error);

                                if (code != ReturnCode.Ok)
                                {
                                    break;
                                }

                                if ((listIndex < 0) ||
                                    (listIndex >= list.Count) ||
                                    (list[listIndex] == null))
                                {
                                    error = String.Format(
                                        "element {0} missing from sublist \"{1}\"",
                                        listIndex, list.ToString());

                                    code = ReturnCode.Error;
                                    break;
                                }

                                localValue = list[listIndex];
                                localIndexList.Add(listIndex);

                                StringList subList = null;

                                code = Parser.SplitList(
                                    interpreter, list[listIndex], 0,
                                    Length.Invalid, true, ref subList,
                                    ref error);

                                if (code == ReturnCode.Ok)
                                {
                                    list = subList;
                                }
                                else
                                {
                                    break;
                                }
                            }

                            if (code == ReturnCode.Ok)
                            {
                                value = localValue;

                                if (clear || (indexList == null))
                                {
                                    indexList = localIndexList;
                                }
                                else
                                {
                                    indexList.AddRange(localIndexList);
                                }
                            }
                        }
                    }
                    else
                    {
                        value = text;

                        if (clear || (indexList == null))
                        {
                            indexList = new IntList();
                        }
                    }
                }
            }
            else
            {
                value = text;

                if (clear || (indexList == null))
                {
                    indexList = new IntList();
                }

                code = ReturnCode.Ok;
            }

            return(code);
        }