當前位置: 首頁>>代碼示例>>C#>>正文


C# Expression.ToExpressionString方法代碼示例

本文整理匯總了C#中System.Linq.Expressions.Expression.ToExpressionString方法的典型用法代碼示例。如果您正苦於以下問題:C# Expression.ToExpressionString方法的具體用法?C# Expression.ToExpressionString怎麽用?C# Expression.ToExpressionString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Linq.Expressions.Expression的用法示例。


在下文中一共展示了Expression.ToExpressionString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: AlertNotText

 public void AlertNotText(Expression<Func<string, bool>> matchFunc)
 {
     var compiledFunc = matchFunc.Compile();
     this.commandProvider.AlertText((alertText) =>
     {
         if (compiledFunc(alertText))
         {
             // because the browser blocks, we dismiss the alert when a failure happens so we can cleanly shutdown.
             this.commandProvider.AlertClick(Alert.Cancel);
             this.ReportError("Expected alert text not to match expression [{0}] but it did.", matchFunc.ToExpressionString());
         }
     });
 }
開發者ID:netusers2014,項目名稱:FluentAutomation,代碼行數:13,代碼來源:AssertProvider.cs

示例2: WaitUntil

        public void WaitUntil(Expression<Func<bool>> conditionFunc, TimeSpan timeout)
        {
            this.Act(() =>
            {
                DateTime dateTimeTimeout = DateTime.Now.Add(timeout);
                bool isFuncValid = false;
                var compiledFunc = conditionFunc.Compile();

                while (DateTime.Now < dateTimeTimeout)
                {
                    if (compiledFunc() == true)
                    {
                        isFuncValid = true;
                        break;
                    }

                    System.Threading.Thread.Sleep(Settings.DefaultWaitUntilThreadSleep);
                }

                // If func is still not valid, assume we've hit the timeout.
                if (isFuncValid == false)
                {
                    throw new FluentException("Conditional wait passed the timeout [{0}ms] for expression [{1}].", timeout.TotalMilliseconds, conditionFunc.ToExpressionString());
                }
            });
        }
開發者ID:couellet,項目名稱:FluentAutomation,代碼行數:26,代碼來源:CommandProvider.cs

示例3: WaitUntil

        public void WaitUntil(Expression<Action> conditionAction, TimeSpan timeout)
        {
            this.Act(CommandType.Wait, () =>
            {
                DateTime dateTimeTimeout = DateTime.Now.Add(timeout);
                bool threwException = false;
                var compiledAction = conditionAction.Compile();

                FluentException lastFluentException = null;
                while (DateTime.Now < dateTimeTimeout)
                {
                    try
                    {
                        threwException = false;
                        compiledAction();
                    }
                    catch (FluentException ex)
                    {
                        threwException = true;
                        lastFluentException = ex;
                    }
                    catch (Exception ex)
                    {
                        throw new FluentException("An unexpected exception was thrown inside WaitUntil(Action). See InnerException for details.", ex);
                    }

                    if (!threwException)
                    {
                        break;
                    }

                    System.Threading.Thread.Sleep(this.Settings.WaitUntilInterval);
                }

                // If an exception was thrown the last loop, assume we hit the timeout
                if (threwException == true)
                {
                    throw new FluentException("Conditional wait passed the timeout [{0}ms] for expression [{1}]. See InnerException for details of the last FluentException thrown.", lastFluentException, timeout.TotalMilliseconds, conditionAction.ToExpressionString());
                }
            });
        }
開發者ID:netusers2014,項目名稱:FluentAutomation,代碼行數:41,代碼來源:BaseCommandProvider.cs

示例4: False

 public void False(Expression<Func<bool>> matchFunc)
 {
     this.commandProvider.Act(() =>
     {
         var compiledFunc = matchFunc.Compile();
         if (compiledFunc())
         {
             throw new FluentExpectFailedException("Expected expression [{0}] to return false.", matchFunc.ToExpressionString());
         }
     });
 }
開發者ID:TroyWalshProf,項目名稱:FluentAutomation,代碼行數:11,代碼來源:ExpectProvider.cs

示例5: Value

        public void Value(Func<IElement> element, Expression<Func<string, bool>> matchFunc)
        {
            this.commandProvider.Act(() =>
            {
                var compiledFunc = matchFunc.Compile();
                var unwrappedElement = element();
                if (unwrappedElement.IsText)
                {
                    if (!compiledFunc(unwrappedElement.Value))
                    {
                        throw new FluentExpectFailedException("Expected TextElement value to match expression [{0}] but it was actually [{1}].", matchFunc.ToExpressionString(), unwrappedElement.Value);
                    }
                }
                else if (unwrappedElement.IsSelect)
                {
                    if (unwrappedElement.IsMultipleSelect)
                    {
                        var foundMatch = false;
                        foreach (var optionValue in unwrappedElement.SelectedOptionValues)
                        {
                            if (compiledFunc(optionValue))
                            {
                                foundMatch = true;
                                break;
                            }
                        }

                        if (!foundMatch)
                        {
                            throw new FluentExpectFailedException("Expected SelectElement selected options to have at least one option with value matching expression[{0}]. Selected option values include [{1}]", matchFunc.ToExpressionString(), string.Join(",", unwrappedElement.SelectedOptionTextCollection));
                        }
                    }
                    else
                    {
                        if (!compiledFunc(unwrappedElement.Text))
                        {
                            throw new FluentExpectFailedException("Expected SelectElement selected option value to match expression [{0}] but it was actually [{1}].", matchFunc.ToExpressionString(), unwrappedElement.Value);
                        }
                    }
                }
                else
                {
                    if (!compiledFunc(unwrappedElement.Value))
                    {
                        throw new FluentExpectFailedException("Expected element value to match expression [{0}] but it was actually [{1}].", matchFunc.ToExpressionString(), unwrappedElement.Value);
                    }
                }
            });
        }
開發者ID:TroyWalshProf,項目名稱:FluentAutomation,代碼行數:49,代碼來源:ExpectProvider.cs

示例6: Url

        public void Url(Expression<Func<Uri, bool>> urlExpression)
        {
            this.commandProvider.Act(() =>
            {
                var compiledExpr = urlExpression.Compile();

                if (compiledExpr(this.commandProvider.Url) != true)
                {
                    throw new FluentExpectFailedException("Expected expression [{0}] to return true.", urlExpression.ToExpressionString());
                }
            });
        }
開發者ID:TroyWalshProf,項目名稱:FluentAutomation,代碼行數:12,代碼來源:ExpectProvider.cs

示例7: NotText

 public void NotText(ElementProxy element, Expression<Func<string, bool>> matchFunc)
 {
     this.commandProvider.Act(commandType, () =>
     {
         var compiledFunc = matchFunc.Compile();
         var result = elementHasText(element, (elText) => compiledFunc(elText));
         if (result.HasText)
         {
             if (element.Element.IsMultipleSelect)
             {
                 this.ReportError("Expected SelectElement [{0}] selected options to have no options with text matching expression [{1}]. Selected option text values include [{2}]", result.Selector, matchFunc.ToExpressionString(), string.Join(",", element.Element.SelectedOptionTextCollection));
             }
             else if (element.Element.IsSelect)
             {
                 this.ReportError("Expected SelectElement [{0}] selected option text not to match expression [{1}] but it did.", result.Selector, matchFunc.ToExpressionString());
             }
             else
             {
                 this.ReportError("Expected {0} [{1}] text not to match expression [{2}] but it did.", result.ElementType, result.Selector, matchFunc.ToExpressionString());
             }
         }
     });
 }
開發者ID:netusers2014,項目名稱:FluentAutomation,代碼行數:23,代碼來源:AssertProvider.cs

示例8: Text

        public void Text(string selector, Expression<Func<string, bool>> matchFunc)
        {
            this.commandProvider.Act(() =>
            {
                var compiledFunc = matchFunc.Compile();
                var unwrappedElement = this.commandProvider.Find(selector)();
                if (unwrappedElement.IsText)
                {
                    if (!compiledFunc(unwrappedElement.Text))
                    {
                        throw new FluentExpectFailedException("Expected TextElement [{0}] text to match expression [{1}] but it was actually [{2}].", selector, matchFunc.ToExpressionString(), unwrappedElement.Text);
                    }
                }
                else if (unwrappedElement.IsSelect)
                {
                    if (unwrappedElement.IsMultipleSelect)
                    {
                        var foundMatch = false;
                        foreach (var optionText in unwrappedElement.SelectedOptionTextCollection)
                        {
                            if (compiledFunc(optionText))
                            {
                                foundMatch = true;
                                break;
                            }
                        }

                        if (!foundMatch)
                        {
                            throw new FluentExpectFailedException("Expected SelectElement [{0}] selected options to have at least one option with text matching expression[{1}]. Selected option text values include [{2}]", selector, matchFunc.ToExpressionString(), string.Join(",", unwrappedElement.SelectedOptionTextCollection));
                        }
                    }
                    else
                    {
                        if (!compiledFunc(unwrappedElement.Text))
                        {
                            throw new FluentExpectFailedException("Expected SelectElement [{0}] selected option text to match expression [{1}] but it was actually [{2}].", selector, matchFunc.ToExpressionString(), unwrappedElement.Text);
                        }
                    }
                }
                else
                {
                    if (!compiledFunc(unwrappedElement.Text))
                    {
                        throw new FluentExpectFailedException("Expected DOM Element [{0}] text to match expression [{1}] but it was actually [{2}].", selector, matchFunc.ToExpressionString(), unwrappedElement.Text);
                    }
                }
            });
        }
開發者ID:TroyWalshProf,項目名稱:FluentAutomation,代碼行數:49,代碼來源:ExpectProvider.cs

示例9: SetValues

        public void SetValues(Expression<Func<string, bool>> optionMatchingExpression, SelectMode selectMode)
        {
            IEnumerable<Automation.Core.Option> options = null;
            var compiledFunc = optionMatchingExpression.Compile();

            if (selectMode == SelectMode.Text)
            {
                options = _element.Options.Where(x => compiledFunc(x.Text));
            }
            else if (selectMode == SelectMode.Value)
            {
                options = _element.Options.Where(x => compiledFunc(x.Value));
            }

            if (options != null)
            {
                foreach (var option in options)
                {
                    option.Select();
                }

                if (options.Count() == 0)
                {
                    if (selectMode == SelectMode.Value)
                        throw new SelectException("Selection failed. No option values matched expression [{0}] on element.", optionMatchingExpression.ToExpressionString());
                    else if (selectMode == SelectMode.Text)
                        throw new SelectException("Selection failed. No option text matched expression [{0}] on element.", optionMatchingExpression.ToExpressionString());
                    else if (selectMode == SelectMode.Index)
                        throw new SelectException("Selection failed. No options matched collection of indices provided.");
                }

                this.OnChange();
            }
        }
開發者ID:Genyus,項目名稱:FluentAutomation,代碼行數:34,代碼來源:SelectElement.cs

示例10: Value

 public void Value(ElementProxy element, Expression<Func<string, bool>> matchFunc)
 {
     this.commandProvider.Act(commandType, () =>
     {
         var compiledFunc = matchFunc.Compile();
         var result = elementHasValue(element, (elValue) => compiledFunc(elValue));
         if (!result.HasValue)
         {
             if (element.Element.IsMultipleSelect)
             {
                 this.ReportError("Expected SelectElement [{0}] selected options to have at least one option with value matching expression [{1}]. Selected option values include [{2}]", result.Selector, matchFunc.ToExpressionString(), string.Join(",", element.Element.SelectedOptionValues));
             }
             else if (element.Element.IsSelect)
             {
                 this.ReportError("Expected SelectElement [{0}] selected option value to match expression [{1}] but it was actually [{2}].", result.Selector, matchFunc.ToExpressionString(), result.ActualValue);
             }
             else
             {
                 this.ReportError("Expected {0} [{1}] value to match expression [{2}] but it was actually [{3}].", result.ElementType, result.Selector, matchFunc.ToExpressionString(), result.ActualValue);
             }
         }
     });
 }
開發者ID:netusers2014,項目名稱:FluentAutomation,代碼行數:23,代碼來源:AssertProvider.cs

示例11: Url

 public void Url(Expression<Func<Uri, bool>> urlExpression)
 {
     this.commandProvider.Act(commandType, () =>
     {
         if (urlExpression.Compile()(this.commandProvider.Url) != true)
         {
             this.ReportError("Expected expression [{0}] to return true. URL was [{1}].", urlExpression.ToExpressionString(), this.commandProvider.Url.ToString());
         }
     });
 }
開發者ID:netusers2014,項目名稱:FluentAutomation,代碼行數:10,代碼來源:AssertProvider.cs

示例12: True

 public void True(Expression<Func<bool>> matchFunc)
 {
     this.commandProvider.Act(commandType, () =>
     {
         var compiledFunc = matchFunc.Compile();
         if (!compiledFunc())
         {
             this.ReportError("Expected expression [{0}] to return true.", matchFunc.ToExpressionString());
         }
     });
 }
開發者ID:netusers2014,項目名稱:FluentAutomation,代碼行數:11,代碼來源:AssertProvider.cs

示例13: Throws

 public void Throws(Expression<Action> matchAction)
 {
     this.commandProvider.Act(commandType, () =>
     {
         if (!throwsException(matchAction))
         {
             this.ReportError("Expected expression [{0}] to throw an exception.", matchAction.ToExpressionString());
         }
     });
 }
開發者ID:netusers2014,項目名稱:FluentAutomation,代碼行數:10,代碼來源:AssertProvider.cs

示例14: Throws

        public void Throws(Expression<Action> matchAction)
        {
            this.commandProvider.Act(() =>
            {
                bool threwException = false;
                var compiledAction = matchAction.Compile();

                try
                {
                    compiledAction();
                }
                catch (FluentExpectFailedException)
                {
                    threwException = true;
                }

                if (!threwException)
                {
                    throw new FluentExpectFailedException("Expected expression [{0}] to throw an exception.", matchAction.ToExpressionString());
                }
            });
        }
開發者ID:TroyWalshProf,項目名稱:FluentAutomation,代碼行數:22,代碼來源:ExpectProvider.cs

示例15: Url

 /// <summary>
 /// Expects page URL matches expression.
 /// </summary>
 /// <param name="valueExpression">The value expression.</param>
 public virtual void Url(Expression<Func<Uri, bool>> valueExpression)
 {
     var _compiledFunc = valueExpression.Compile();
     if (!_compiledFunc(Provider.GetUri()))
     {
         Provider.TakeAssertExceptionScreenshot();
         throw new AssertException("URL Assertion failed. Expected URL to match expression [{0}]. Actual URL is [{1}].", valueExpression.ToExpressionString(), Provider.GetUri());
     }
 }
開發者ID:Genyus,項目名稱:FluentAutomation,代碼行數:13,代碼來源:ExpectManager.cs


注:本文中的System.Linq.Expressions.Expression.ToExpressionString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。