Ejemplo n.º 1
0
 public bool IsContainedIn(IFilter[] filters)
 {
     for (int i = 0; i < filters.Length; ++i)
     {
         if (filters[i] is IFilterAutoGenerated)
         {
             IFilterAutoGenerated filter = (IFilterAutoGenerated)filters[i];
             if (filter.PackagePrefixedName == PackagePrefixedName)
             {
                 if (Name == "auto")
                 {
                     return(true);
                 }
                 else if (filter.Entity == Entity)
                 {
                     return(true);
                 }
             }
         }
         else //if(filters[i] is IFilterFunction)
         {
             IFilterFunction filter = (IFilterFunction)filters[i];
             if (filter.PackagePrefixedName == PackagePrefixedName)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Finds an element using the element name.
        /// </summary>
        /// <param name="driver">The <see cref="IWebDriver"/> to use in finding the element.</param>
        /// <param name="use">The locator string to use.</param>
        /// <returns>An <see cref="IWebElement"/> that matches the locator string.</returns>
        public IWebElement Find(OpenQA.Selenium.IWebDriver driver, string use)
        {
            string[] parts = use.Split(new char[] { ' ' });

            ReadOnlyCollection <IWebElement> allElements = driver.FindElements(By.Name(parts[0]));
            IList <IWebElement> filteredElements         = new List <IWebElement>(allElements);

            for (int i = 1; i < parts.Length; i++)
            {
                IFilterFunction filterBy = this.GetFilterFunction(parts[i]);

                if (filterBy == null)
                {
                    throw new SeleniumException(use + " not found. Cannot find filter for: " + parts[i]);
                }

                string filterValue = this.GetFilterValue(parts[i]);
                filteredElements = filterBy.FilterElements(allElements, filterValue);
            }

            if (filteredElements != null && filteredElements.Count > 0)
            {
                return(filteredElements[0]);
            }

            throw new SeleniumException(use + " not found");
        }
Ejemplo n.º 3
0
        public static List <ValuePath> ParsePropertyPaths(this ParseContext context)
        {
            List <ValuePath> names = new List <ValuePath>();

            while (context.NotEnd())
            {
                var name = ParseName(context);
                context.SkipWhiteSpace();
                if (context.End())
                {
                    names.Add(new ValuePath {
                        Name = name
                    });
                    break;
                }
                else if (context.Current() == '.')
                {
                    // a.b
                    names.Add(new ValuePath {
                        Name = name
                    });
                    context.Index++;
                }

                else if (context.Current() == '(')
                {
                    var args     = IFilterFunction.ParseFunctionArgument(name, context);
                    var nameInfo = new ValuePath {
                        Name = name, IsFunction = true, FunctionArgs = args
                    };
                    context.SkipWhiteSpace();
                    names.Add(nameInfo);
                    if (context.NotEnd())
                    {
                        if (context.Current() == '.')
                        {
                            context.Index++;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                else
                {
                    names.Add(new ValuePath {
                        Name = name
                    });
                    break;
                }
            }
            return(names);
        }
Ejemplo n.º 4
0
 private string FilterFunctionParameterType(int i, SequenceFilterCall sequenceFilterCall)
 {
     if (sequenceFilterCall.Filter is IFilterAutoSupplied)
     {
         IFilterAutoSupplied filterAutoSupplied = (IFilterAutoSupplied)sequenceFilterCall.Filter;
         return(TypesHelper.DotNetTypeToXgrsType(filterAutoSupplied.Inputs[i]));
     }
     if (sequenceFilterCall.Filter is IFilterFunction)
     {
         IFilterFunction filterFunction = (IFilterFunction)sequenceFilterCall.Filter;
         return(TypesHelper.DotNetTypeToXgrsType(filterFunction.Inputs[i]));
     }
     throw new Exception("Internal error"); // auto-generated
 }
Ejemplo n.º 5
0
 private int NumFilterFunctionParameters(SequenceFilterCall sequenceFilterCall)
 {
     if (sequenceFilterCall.Filter is IFilterAutoSupplied)
     {
         IFilterAutoSupplied filterAutoSupplied = (IFilterAutoSupplied)sequenceFilterCall.Filter;
         return(filterAutoSupplied.Inputs.Length);
     }
     if (sequenceFilterCall.Filter is IFilterFunction)
     {
         IFilterFunction filterFunction = (IFilterFunction)sequenceFilterCall.Filter;
         return(filterFunction.Inputs.Length);
     }
     return(0); // auto-generated
 }
Ejemplo n.º 6
0
        private (Type ReturnType, Expression Body) CreateLambdaBody(ParameterExpression p, List <ValuePath> pathInfos, IMemberVisitor memberProvider)
        {
            IMemberVisitor currentMemberProvider = memberProvider;
            Type           currentExpressionType = currentMemberProvider.CurrentType;
            Expression     currentExpression     = p;

            foreach (var pathInfo in pathInfos.TrimNotNull())
            {
                if (pathInfo.IsFunction)
                {
                    var functionResult = IFilterFunction.ExecuteFunction(pathInfo.Name, pathInfo.FunctionArgs, new ExecuteContext
                    {
                        CurrentExpression = currentExpression,
                        MemberVisitor     = currentMemberProvider,
                        CurrentType       = currentExpressionType,
                    });
                    currentExpressionType = functionResult.LambdaValueType;
                    currentExpression     = currentExpression.Connect(functionResult.LambdaExpression);
                    currentMemberProvider = functionResult.MemberProvider;
                }
                else
                {
                    var memberInfo = currentMemberProvider.GetSubMemberInfo(pathInfo.Name);

                    if (memberInfo == null)
                    {
                        throw ExpressionErrors.MemberNotFound(pathInfo.Name);
                    }
                    else
                    {
                        currentExpressionType = memberInfo.ExpressionValueType;
                        currentExpression     = currentExpression.Connect(memberInfo.SelectExpression);
                        currentMemberProvider = memberInfo.SubProvider;
                    }
                }
            }
            return(currentExpressionType, currentExpression);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Applies a Filter transformation on a <see cref="DataStream{T}"/>.
 /// The transformation calls a <see cref="IFilterFunction{T}"/> for each element of the DataStream and retains only those element for which the function returns true. Elements for which the function returns false are filtered. The user can also extend <see cref="IRichFunction"/> to gain access to other features provided by the <see cref="IRichFunction"/> interface.
 /// </summary>
 /// <param name="filter">The FilterFunction that is called for each element of the DataStream.</param>
 /// <returns>The filtered DataStream.</returns>
 public SingleOutputStreamOperator <TElement> Filter(IFilterFunction <TElement> filter)
 {
     return(null);
 }