Exemplo n.º 1
0
        /// <summary>
        /// 子を実行する。
        /// </summary>
        /// <param name="runChildren"></param>
        /// <param name="list"></param>
        protected void RunChildrenForArray <T>(bool runChildren, IEnumerable <T> list, Func <T, string> textFunc, Action <T> action)
        {
            if (runChildren)
            {
                List <TextPair <T> > dataList = list.Select(n => new TextPair <T> {
                    Text = textFunc(n), Obj = n
                }).ToList();
                if (ConvertTree != null)
                {
                    dataList = Convert <T>(dataList, textFunc).ToList();
                }
                if (Query != null)
                {
                    dataList = Query.RunQuery(dataList, this).ToList();
                }
                dataList = DoElementAt <TextPair <T> >(dataList).ToList();

                SetTexts(dataList.Select(n => n.Text));

                foreach (var item in dataList)
                {
                    this.SetText(item.Text);
                    action(item.Obj);
                    foreach (RawlerBase item2 in children)
                    {
                        item2.Run();
                        if (item2.GetBreakFlag())
                        {
                            break;
                        }
                    }
                }
                foreach (var item in children)
                {
                    item.Completed();
                }
                if (LoopEndEvent != null)
                {
                    LoopEndEvent(this, new EventArgs());
                }
                if (EmptyTree != null)
                {
                    if (list.Any() == false)
                    {
                        EmptyTree.SetParent(this);
                        EmptyTree.Run();
                    }
                }
                if (AnyTree != null)
                {
                    if (list.Any() == true)
                    {
                        AnyTree.SetParent(this);
                        AnyTree.Run();
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 子を実行する。
        /// </summary>
        /// <param name="runChildren"></param>
        /// <param name="list"></param>
        protected void RunChildrenForArray(bool runChildren, IEnumerable <string> list)
        {
            if (runChildren)
            {
                if (ConvertTree != null)
                {
                    list = Convert(list);
                }
                if (Query != null)
                {
                    list = Query.RunQuery(list, this);
                }
                list = DoElementAt <string>(list);
                SetTexts(list);

                foreach (var item in list)
                {
                    this.SetText(item);

                    foreach (RawlerBase item2 in children)
                    {
                        item2.Run();
                        if (item2.GetBreakFlag())
                        {
                            break;
                        }
                    }
                }

                if (LoopEndEvent != null)
                {
                    LoopEndEvent(this, new EventArgs());
                }
                if (EmptyTree != null)
                {
                    if (list.Any() == false)
                    {
                        EmptyTree.SetParent(this);
                        EmptyTree.Run();
                    }
                }
                if (AnyTree != null)
                {
                    if (list.Any() == true)
                    {
                        AnyTree.SetParent(this);
                        AnyTree.Run();
                    }
                }
            }
        }