Example #1
0
        protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state)
        {
            try
            {
                m_Delegate = new runDelegate(Run);
                string    filterText = FilterText.Get(context);
                TreeScope treeScope;
                if (Scope == ScopeOption.Children)
                {
                    treeScope = TreeScope.Children;
                }
                else if (Scope == ScopeOption.Descendants)
                {
                    treeScope = TreeScope.Descendants;
                }
                else
                {
                    treeScope = TreeScope.Subtree;
                }
                UiElement element = null;
                var       selStr  = Selector.Get(context);


                element = Common.GetValueOrDefault(context, this.Element, null);
                if (element == null && selStr != null)
                {
                    element = UiElement.FromSelector(selStr);
                }
                else
                {
                    PropertyDescriptor property = context.DataContext.GetProperties()[EleScope.GetEleScope];
                    element = property.GetValue(context.DataContext) as UiElement;
                }

                List <UiElement> uiList = new List <UiElement>();
                uiList = element.FindAllByFilter(treeScope, TrueCondition.Default, filterText);
                UiList.Set(context, uiList);

                return(m_Delegate.BeginInvoke(callback, state));
            }
            catch (Exception e)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, "获取子节点元素失败", e.Message);
                if (ContinueOnError.Get(context))
                {
                    return(m_Delegate.BeginInvoke(callback, state));
                }
                else
                {
                    throw e;
                }
            }
        }