示例#1
0
        private void zCreateDataSetIterator(DataSetIteration iteration)
        {
            DataSetIterator   iterator          = new DataSetIterator(iteration);
            ListStateVariable listStateVariable = (ListStateVariable)CurrentScope.DataScope.GetStateVariable(iteration.ObjectSetListName);

            iterator.SetDataSet(listStateVariable.Value.OfType <ObjectStateVariable>());
            zCompleteGroupStep(iterator);
        }
        private void zReadTableResult(DataReaderHelper reader)
        {
            TableResultMapping tableResultMapping = (TableResultMapping)m_Step.ResultMapping;

            ListStateVariable listStateVariable = null;

            if (tableResultMapping.ObjectSetListName != null && tableResultMapping.ObjectSetClassName != null)
            {
                //TODO: there is similar logic in GroupStepExecutor.zCreateElementSetIterator - refactor into common method on DataScope.
                listStateVariable = (ListStateVariable)CurrentScope.DataScope.GetStateVariable(tableResultMapping.ObjectSetListName);
                if (listStateVariable == null)
                {
                    listStateVariable = new ListStateVariable(DataUtils.GetUnscopedVariableName(tableResultMapping.ObjectSetListName), tableResultMapping.PersistenceMode, new List <IStateVariable>());
                    CurrentScope.DataScope.SetStateVariable(tableResultMapping.ObjectSetListName, listStateVariable);
                }
                listStateVariable.IncludeInXML = tableResultMapping.IncludeInXML;
            }

            int resultCount = 1;

            while (reader.Read())
            {
                ObjectStateVariable objectStateVariable = null;
                if (listStateVariable != null)
                {
                    string listItemName = String.Format("{0}{1}", tableResultMapping.ObjectSetClassName, resultCount);
                    objectStateVariable = new ObjectStateVariable(listItemName, tableResultMapping.ObjectSetClassName, tableResultMapping.PersistenceMode, new Dictionary <string, IStateVariable>());
                    listStateVariable.Value.Add(objectStateVariable);
                }

                foreach (TableResultMap tableMap in tableResultMapping.TableMapping)
                {
                    //TODO: for now all data is being converted to string. Once we are doing something with the variable type system,
                    //      type the variables appropriately when reading them in.
                    object         value         = reader.GetNullableValue(tableMap.ColumnName);
                    IStateVariable stateVariable = new StateVariable <string>(DataUtils.GetUnscopedVariableName(tableMap.StateVariable),
                                                                              DataType.String,
                                                                              tableMap.XMLFieldOutputMode,
                                                                              tableMap.PersistenceMode,
                                                                              Convert.ToString(value));
                    if (objectStateVariable != null && stateVariable.Name == tableMap.StateVariable)
                    {
                        //stateVariable.Name == tableMap.StateVariable checks that tableMap.StateVariable has no explicit scope.
                        //If it has an explicit scope, stateVariable has to be set through CurrentScope.DataScope in the else block.
                        objectStateVariable.Value.Add(tableMap.StateVariable, stateVariable);
                    }
                    else
                    {
                        CurrentScope.DataScope.SetStateVariable(tableMap.StateVariable, stateVariable);
                    }
                }

                resultCount++;
            }
        }
示例#3
0
 private void zRecursiveClearVariable(IStateVariable stateVariable)
 {
     if (stateVariable is ObjectStateVariable)
     {
         ObjectStateVariable objectStateVariable = (ObjectStateVariable)stateVariable;
         zRecursiveClearStateVariableCollection(objectStateVariable.Value.Values);
         objectStateVariable.Value.Clear();
     }
     if (stateVariable is ListStateVariable)
     {
         ListStateVariable listStateVariable = (ListStateVariable)stateVariable;
         zRecursiveClearStateVariableCollection(listStateVariable.Value);
         listStateVariable.Value.Clear();
     }
 }
示例#4
0
        private void zCreateElementSetIterator(ElementSetIteration iteration)
        {
            ListStateVariable listStateVariable = null;

            if (iteration.IsSetIteration)
            {
                listStateVariable = (ListStateVariable)CurrentScope.DataScope.GetStateVariable(iteration.ObjectSetListName);
                if (listStateVariable == null)
                {
                    listStateVariable = new ListStateVariable(DataUtils.GetUnscopedVariableName(iteration.ObjectSetListName), iteration.PersistenceMode, new List <IStateVariable>());
                    CurrentScope.DataScope.SetStateVariable(iteration.ObjectSetListName, listStateVariable);
                }
                listStateVariable.IncludeInXML = iteration.IncludeInXML;
            }
            ElementSetIterator iterator = new ElementSetIterator(iteration, listStateVariable);

            ElementIdentifier containerIdentifier = zGetElementSetContainer(iteration);

            ThreadingUtils.InvokeControlAction(m_Context.BrowserHelper.Browser, ctl =>
            {
                if (iteration.ElementType == Model.Automation.ElementType.Static)
                {
                    List <HtmlElement> containerElements = m_Context.BrowserHelper.FindElements(containerIdentifier, CurrentScope.ElementSetIteratorItem);
                    iterator.SetElements(containerElements);
                    zCompleteGroupStep(iterator);
                }
                else
                {
                    m_Context.BrowserHelper.PollElements(containerIdentifier, CurrentScope.ElementSetIteratorItem, iteration.PollingTimeout.Value, containerElements =>
                    {
                        iterator.SetElements(containerElements);
                        zCompleteGroupStep(iterator);
                    });
                }
            });
        }
 public ElementSetIterator(ElementSetIteration iteration, ListStateVariable listStateVariable) : base(iteration)
 {
     m_Elements          = new List <HtmlElement>();
     m_ListStateVariable = listStateVariable;
 }