Here are the examples of the csharp api System.Linq.Expressions.ExpressionVisitor.Visit(System.Linq.Expressions.Expression) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
856 Examples
19
View Source File : ExpressionResovle.cs
License : Apache License 2.0
Project Creator : 1448376744
License : Apache License 2.0
Project Creator : 1448376744
public virtual string Resovle()
{
Visit(_expression);
return _textBuilder.ToString();
}
19
View Source File : DataFilterUtil.cs
License : MIT License
Project Creator : 2881099
License : MIT License
Project Creator : 2881099
public Expression Modify(Expression expression, ParameterExpression parameter) {
this.parameter = parameter;
return Visit(expression);
}
19
View Source File : JoinClause.cs
License : MIT License
Project Creator : 71
License : MIT License
Project Creator : 71
protected internal override QueryClause VisitChildren(ExpressionVisitor visitor)
=> Update(visitor.VisitAndConvert(Variable, nameof(VisitChildren)), visitor.Visit(Enumerable), visitor.Visit(Left), visitor.Visit(Right));
19
View Source File : JoinIntoClause.cs
License : MIT License
Project Creator : 71
License : MIT License
Project Creator : 71
protected internal override QueryClause VisitChildren(ExpressionVisitor visitor)
=> Update(visitor.VisitAndConvert(Variable, nameof(VisitChildren)), visitor.Visit(Enumerable), visitor.Visit(Left), visitor.Visit(Right), visitor.VisitAndConvert(Group, nameof(VisitChildren)));
19
View Source File : SelectClause.cs
License : MIT License
Project Creator : 71
License : MIT License
Project Creator : 71
protected internal override QueryClause VisitChildren(ExpressionVisitor visitor)
=> Update(visitor.Visit(Selector));
19
View Source File : WhereClause.cs
License : MIT License
Project Creator : 71
License : MIT License
Project Creator : 71
protected internal override QueryClause VisitChildren(ExpressionVisitor visitor)
=> Update(visitor.Visit(Condition));
19
View Source File : ForEachExpression.cs
License : MIT License
Project Creator : 71
License : MIT License
Project Creator : 71
protected override Expression VisitChildren(ExpressionVisitor visitor)
=> Update(visitor.VisitAndConvert(Variable, nameof(ForEachExpression.VisitChildren)),
visitor.Visit(Enumerable), visitor.Visit(Body),
BreakLabel, ContinueLabel);
19
View Source File : WhileExpression.cs
License : MIT License
Project Creator : 71
License : MIT License
Project Creator : 71
protected override Expression VisitChildren(ExpressionVisitor visitor)
=> Update(visitor.Visit(Test), visitor.Visit(Body), ContinueLabel, BreakLabel);
19
View Source File : AsyncExpression.cs
License : MIT License
Project Creator : 71
License : MIT License
Project Creator : 71
protected override Expression VisitChildren(ExpressionVisitor visitor)
=> Update(visitor.Visit(Body));
19
View Source File : YieldExpression.cs
License : MIT License
Project Creator : 71
License : MIT License
Project Creator : 71
protected override Expression VisitChildren(ExpressionVisitor visitor)
=> Update(visitor.Visit(Expression));
19
View Source File : LockExpression.cs
License : MIT License
Project Creator : 71
License : MIT License
Project Creator : 71
protected override Expression VisitChildren(ExpressionVisitor visitor)
=> Update(visitor.Visit(Object), visitor.Visit(Body));
19
View Source File : FromClause.cs
License : MIT License
Project Creator : 71
License : MIT License
Project Creator : 71
protected internal override QueryClause VisitChildren(ExpressionVisitor visitor)
=> Update(visitor.VisitAndConvert(Variable, nameof(VisitChildren)), visitor.Visit(Enumerable));
19
View Source File : GroupByClause.cs
License : MIT License
Project Creator : 71
License : MIT License
Project Creator : 71
protected internal override QueryClause VisitChildren(ExpressionVisitor visitor)
=> Update(visitor.VisitAndConvert(Variable, nameof(VisitChildren)), visitor.Visit(Selector));
19
View Source File : GroupByIntoClause.cs
License : MIT License
Project Creator : 71
License : MIT License
Project Creator : 71
protected internal override QueryClause VisitChildren(ExpressionVisitor visitor)
=> Update(visitor.VisitAndConvert(Variable, nameof(VisitChildren)), visitor.Visit(Selector), visitor.VisitAndConvert(Group, nameof(VisitChildren)));
19
View Source File : IteratorExpression.cs
License : MIT License
Project Creator : 71
License : MIT License
Project Creator : 71
protected override Expression VisitChildren(ExpressionVisitor visitor)
=> Update(visitor.Visit(Iterator));
19
View Source File : LetClause.cs
License : MIT License
Project Creator : 71
License : MIT License
Project Creator : 71
protected internal override QueryClause VisitChildren(ExpressionVisitor visitor)
=> Update(visitor.VisitAndConvert(Variable, nameof(VisitChildren)), visitor.Visit(Expression));
19
View Source File : ForExpression.cs
License : MIT License
Project Creator : 71
License : MIT License
Project Creator : 71
protected override Expression VisitChildren(ExpressionVisitor visitor)
=> Update(visitor.VisitAndConvert(Variable, nameof(VisitChildren)),
visitor.Visit(Initializer), visitor.Visit(Test),
visitor.Visit(Step), visitor.Visit(Body),
BreakLabel, ContinueLabel);
19
View Source File : AwaitExpression.cs
License : MIT License
Project Creator : 71
License : MIT License
Project Creator : 71
protected override Expression VisitChildren(ExpressionVisitor visitor)
=> Update(visitor.Visit(Expression), Method);
19
View Source File : QueryExpression.Parser.cs
License : MIT License
Project Creator : 71
License : MIT License
Project Creator : 71
public override Expression Visit(Expression node)
{
if (node == null)
return null;
return base.Visit(node);
}
19
View Source File : LinkedExpression.cs
License : MIT License
Project Creator : 71
License : MIT License
Project Creator : 71
protected override Expression Accept(ExpressionVisitor visitor) => visitor.Visit(Reduce());
19
View Source File : UsingExpression.cs
License : MIT License
Project Creator : 71
License : MIT License
Project Creator : 71
protected override Expression VisitChildren(ExpressionVisitor visitor)
=> Update(visitor.VisitAndConvert(Variable, nameof(VisitChildren)), visitor.Visit(Disposable), visitor.Visit(Body));
19
View Source File : TrackingExpressionVisitor.cs
License : MIT License
Project Creator : 71
License : MIT License
Project Creator : 71
public override Expression Visit(Expression node)
{
if (node == null)
return null;
if (Projector != null)
{
// Project things in here, to avoid traversing the tree multiple times
// ReSharper disable once PossibleInvalidCastExceptionInForeachLoop
foreach (ExpressionProjector projector in Projector.GetInvocationList())
node = projector(node);
}
node = node.ReduceExtensions();
if (node is BlockExpression block)
// Make sure we don't have smaller scopes that would break the variable replacedignements
node = block.Update(Enumerable.Empty<ParameterExpression>(), block.Expressions);
if (node is ParameterExpression variable && !Variables.Contains(variable) && !variable.IsreplacedignableTo<VirtualStateMachine>())
// Keep track of variable
Variables.Add(variable);
if (node.NodeType == ExpressionType.Extension && !node.CanReduce)
// In case we're returning a special expression (ie: YieldExpression)
return node;
return base.Visit(node);
}
19
View Source File : ExpressionPipeline.cs
License : MIT License
Project Creator : 71
License : MIT License
Project Creator : 71
[SuppressMessage("ReSharper", "PossibleNullReferenceException")]
public override Expression Visit(Expression node)
{
if (_isStopped)
return node;
if (_visitedExpressions != null && _visitedExpressions.Contains(node))
return node;
if (Pipeline != null)
{
Delegate[] projectors = Pipeline.GetInvocationList();
for (int i = 0; i < projectors.Length; i++)
{
node = (projectors[i] as ExpressionProjector).Invoke(node);
if (node == null)
return null;
}
}
_visitedExpressions?.Add(node);
return node.NodeType == ExpressionType.Extension && !node.CanReduce ? node : base.Visit(node);
}
19
View Source File : ScopedExpressionVisitor.cs
License : MIT License
Project Creator : 71
License : MIT License
Project Creator : 71
public override Expression Visit(Expression node)
{
if (node == null)
return null;
EnsureCapacity(_depth + 1);
_scope[_depth++] = node;
base.Visit(node);
node = Visit(new ScopedExpression(this, --_depth));
_scope[_depth] = null;
return node;
}
19
View Source File : DynamicUtils.cs
License : MIT License
Project Creator : akaskela
License : MIT License
Project Creator : akaskela
public override DynamicMetaObject FallbackGetMember(DynamicMetaObject target, DynamicMetaObject errorSuggestion)
{
DynamicMetaObject retMetaObject = _innerBinder.Bind(target, new DynamicMetaObject[] { });
NoThrowExpressionVisitor noThrowVisitor = new NoThrowExpressionVisitor();
Expression resultExpression = noThrowVisitor.Visit(retMetaObject.Expression);
DynamicMetaObject finalMetaObject = new DynamicMetaObject(resultExpression, retMetaObject.Restrictions);
return finalMetaObject;
}
19
View Source File : DynamicUtils.cs
License : MIT License
Project Creator : akaskela
License : MIT License
Project Creator : akaskela
public override DynamicMetaObject FallbackSetMember(DynamicMetaObject target, DynamicMetaObject value, DynamicMetaObject errorSuggestion)
{
DynamicMetaObject retMetaObject = _innerBinder.Bind(target, new DynamicMetaObject[] { value });
NoThrowExpressionVisitor noThrowVisitor = new NoThrowExpressionVisitor();
Expression resultExpression = noThrowVisitor.Visit(retMetaObject.Expression);
DynamicMetaObject finalMetaObject = new DynamicMetaObject(resultExpression, retMetaObject.Restrictions);
return finalMetaObject;
}
19
View Source File : WeakTypeDelegateGenerator.cs
License : MIT License
Project Creator : albyho
License : MIT License
Project Creator : albyho
public Delegate Generate(Expression exp)
{
_parameters = new List<ParameterExpression>();
var body = this.Visit(exp);
var lambda = Expression.Lambda(body, _parameters.ToArray());
return lambda.Compile();
}
19
View Source File : QueryableExtensions.cs
License : MIT License
Project Creator : albyho
License : MIT License
Project Creator : albyho
public override Expression Visit(Expression exp)
{
if (exp == _oldParam)
{
return _replacement;
}
return base.Visit(exp);
}
19
View Source File : ConstantExtractor.cs
License : MIT License
Project Creator : albyho
License : MIT License
Project Creator : albyho
public List<object> Extract(Expression exp)
{
_constants = new List<object>();
Visit(exp);
return _constants;
}
19
View Source File : DelegateGenerator.cs
License : MIT License
Project Creator : albyho
License : MIT License
Project Creator : albyho
public Func<List<object>, object> Generate(Expression exp)
{
_parameterCount = 0;
_parametersExpression =
Expression.Parameter(typeof(List<object>), "parameters");
var body = this.Visit(exp); // normalize
if (body.Type != typeof(object))
{
body = Expression.Convert(body, typeof(object));
}
var lambda = Expression.Lambda<Func<List<object>, object>>(body, _parametersExpression);
return lambda.Compile();
}
19
View Source File : PartialEvaluatorBase.cs
License : MIT License
Project Creator : albyho
License : MIT License
Project Creator : albyho
protected override Expression Visit(Expression exp)
{
if (exp == null)
{
return null;
}
if (_candidates.Contains(exp))
{
return exp.NodeType == ExpressionType.Constant ? exp :
Expression.Constant(_evaluator.Eval(exp), exp.Type);
}
return base.Visit(exp);
}
19
View Source File : PartialEvaluatorBase.cs
License : MIT License
Project Creator : albyho
License : MIT License
Project Creator : albyho
protected override Expression Visit(Expression expression)
{
if (expression != null)
{
bool saveCannotBeEvaluated = _cannotBeEvaluated;
_cannotBeEvaluated = false;
base.Visit(expression);
if (!_cannotBeEvaluated)
{
if (_fnCanBeEvaluated(expression))
{
_candidates.Add(expression);
}
else
{
_cannotBeEvaluated = true;
}
}
_cannotBeEvaluated |= saveCannotBeEvaluated;
}
return expression;
}
19
View Source File : ExpressionHasher.cs
License : MIT License
Project Creator : albyho
License : MIT License
Project Creator : albyho
protected override Expression Visit(Expression exp)
{
if (exp == null) return exp;
Hash((int)exp.NodeType).Hash(exp.Type);
return base.Visit(exp);
}
19
View Source File : Evaluator.cs
License : MIT License
Project Creator : AlenToma
License : MIT License
Project Creator : AlenToma
public override Expression Visit(Expression exp)
{
if (exp == null)
{
return null;
}
if (this.candidates.Contains(exp))
{
return this.Evaluate(exp);
}
return base.Visit(exp);
}
19
View Source File : Evaluator.cs
License : MIT License
Project Creator : AlenToma
License : MIT License
Project Creator : AlenToma
public override Expression Visit(Expression expression)
{
if (expression != null)
{
bool saveCannotBeEvaluated = this.cannotBeEvaluated;
this.cannotBeEvaluated = false;
base.Visit(expression);
if (!this.cannotBeEvaluated)
{
if (this.fnCanBeEvaluated(expression))
{
this.candidates.Add(expression);
}
else
{
this.cannotBeEvaluated = true;
}
}
this.cannotBeEvaluated |= saveCannotBeEvaluated;
}
return expression;
}
19
View Source File : LinqToSql.cs
License : MIT License
Project Creator : AlenToma
License : MIT License
Project Creator : AlenToma
public override Expression Visit(Expression node)
{
var m = base.Visit(node);
_overridedNodeType = null;
return m;
}
19
View Source File : PredicateBuilder.cs
License : MIT License
Project Creator : alirezanet
License : MIT License
Project Creator : alirezanet
public override Expression Visit(Expression node)
{
return node == _oldValue ? _newValue : base.Visit(node)!;
}
19
View Source File : DdbExpressionVisitor.cs
License : MIT License
Project Creator : AllocZero
License : MIT License
Project Creator : AllocZero
protected override Expression VisitMember(MemberExpression node)
{
if (node.Expression is ConstantExpression constantExpression && node.Member is FieldInfo fieldInfo)
{
var value = fieldInfo.GetValue(constantExpression.Value);
_builder.Append(value);
return node;
}
if (node.Expression!.NodeType != ExpressionType.Parameter)
Visit(node.Expression);
if (_builder.Length > 0)
_builder.Append('.');
_builder.Append("#f");
_builder.Append(_cachedAttributeNames!.Count);
if (!ClreplacedInfo.PropertiesMap.TryGetValue(node.Member.Name, out var ddbPropertyInfo))
throw new DdbException(
$"Property {node.Member.Name} does not exist in enreplacedy {ClreplacedInfo.Type.Name} or it's not marked by {nameof(DynamoDbPropertyAttribute)} attribute");
_cachedAttributeNames.Add(ddbPropertyInfo.AttributeName);
ClreplacedInfo = ddbPropertyInfo.RuntimeClreplacedInfo;
return node;
}
19
View Source File : DdbExpressionVisitor.cs
License : MIT License
Project Creator : AllocZero
License : MIT License
Project Creator : AllocZero
protected override Expression VisitBinary(BinaryExpression node)
{
if (node.NodeType == ExpressionType.ArrayIndex)
{
Visit(node.Left);
_builder.Append('[');
Visit(node.Right);
_builder.Append(']');
ClreplacedInfo = ClreplacedInfo.ElementClreplacedInfo!;
}
return node;
}
19
View Source File : DdbExpressionVisitor.cs
License : MIT License
Project Creator : AllocZero
License : MIT License
Project Creator : AllocZero
protected override Expression VisitIndex(IndexExpression node)
{
if (node.Object!.NodeType != ExpressionType.Parameter)
Visit(node.Object);
_builder.Append('[');
Visit(node.Arguments);
_builder.Append(']');
ClreplacedInfo = ClreplacedInfo.ElementClreplacedInfo!;
return node;
}
19
View Source File : DdbExpressionVisitor.cs
License : MIT License
Project Creator : AllocZero
License : MIT License
Project Creator : AllocZero
protected override Expression VisitMethodCall(MethodCallExpression node)
{
if (node.Method.IsSpecialName && node.Method.Name == "get_Item")
{
Visit(node.Object);
if ((ClreplacedInfo.ClreplacedType & DdbClreplacedType.Dictionary) != 0)
{
_builder.Append('.');
Visit(node.Arguments);
}
else
{
_builder.Append('[');
Visit(node.Arguments);
_builder.Append(']');
}
ClreplacedInfo = ClreplacedInfo.ElementClreplacedInfo!;
}
return node;
}
19
View Source File : DdbExpressionVisitor.cs
License : MIT License
Project Creator : AllocZero
License : MIT License
Project Creator : AllocZero
public void Visit<TEnreplacedy>(Expression expression)
{
var enreplacedyType = typeof(TEnreplacedy);
ClreplacedInfo = _metadata.GetOrAddClreplacedInfo(enreplacedyType);
_builder.Clear();
Visit(expression);
}
19
View Source File : DdbExpressionVisitor.cs
License : MIT License
Project Creator : AllocZero
License : MIT License
Project Creator : AllocZero
public void Visit(DdbClreplacedInfo clreplacedInfo, Expression expression)
{
ClreplacedInfo = clreplacedInfo;
_builder.Clear();
Visit(expression);
}
19
View Source File : ExpressionLogicalOperatorsExtension .cs
License : MIT License
Project Creator : AlphaYu
License : MIT License
Project Creator : AlphaYu
public override Expression Visit(Expression node)
{
if (node == _oldValue)
return _newValue;
return base.Visit(node);
}
19
View Source File : ExpressionExtensions.cs
License : Apache License 2.0
Project Creator : AndcultureCode
License : Apache License 2.0
Project Creator : AndcultureCode
public override Expression Visit(Expression node)
{
return node == _oldValue ? _newValue : base.Visit(node);
}
19
View Source File : ExpressionBuilder.cs
License : MIT License
Project Creator : ansel86castro
License : MIT License
Project Creator : ansel86castro
public static Expression<Func<T, bool>> Combine<T>(Expression<Func<T, bool>> exp1, Expression<Func<T, bool>> exp2, bool or)
{
if (exp1 == null && exp2 == null) return null;
else if (exp1 == null) return exp2;
else if (exp2 == null) return exp1;
var body1 = exp1.Body;
var body2 = exp2.Body;
var parameter = exp1.Parameters[0];
Expression exp = or ? Expression.OrElse(exp1, exp2) : Expression.AndAlso(exp1, exp2);
ParamExpresionVisitor visitor = new ParamExpresionVisitor { ReplaceParameter = parameter };
exp = visitor.Visit(exp);
return Expression.Lambda<Func<T, bool>>(exp, parameter);
}
19
View Source File : ExpressionBuilder.cs
License : MIT License
Project Creator : ansel86castro
License : MIT License
Project Creator : ansel86castro
public static Expression<Func<T1, bool>> Combine<T1, T2>(Expression<Func<T1, T2>> targetExp, Expression<Func<T2, bool>> expression)
{
ParamExpresionVisitor visitor = new ParamExpresionVisitor { ReplaceParameter = targetExp.Body };
var exp = visitor.Visit(expression.Body);
Expression current = targetExp.Body;
while (current != null && !(current is ParameterExpression))
{
current = ((MemberExpression)current).Expression;
}
return Expression.Lambda<Func<T1, bool>>(exp, (ParameterExpression)current);
}
19
View Source File : ExpressionBuilder.cs
License : MIT License
Project Creator : ansel86castro
License : MIT License
Project Creator : ansel86castro
public static Expression<Func<T1, object>> Combine<T1, T2>(Expression<Func<T1, T2>> targetExp, Expression<Func<T2, object>> expression)
{
ParamExpresionVisitor visitor = new ParamExpresionVisitor { ReplaceParameter = targetExp.Body };
var exp = visitor.Visit(expression.Body);
Expression current = targetExp.Body;
while (current != null && !(current is ParameterExpression))
{
current = ((MemberExpression)current).Expression;
}
return Expression.Lambda<Func<T1, object>>(exp, (ParameterExpression)current);
}
19
View Source File : PartialEvaluator.cs
License : MIT License
Project Creator : anthonyreilly
License : MIT License
Project Creator : anthonyreilly
protected override Expression Visit(Expression exp)
{
if (exp == null)
{
return null;
}
if (this.candidates.Contains(exp))
{
return this.Evaluate(exp);
}
return base.Visit(exp);
}
19
View Source File : PartialEvaluator.cs
License : MIT License
Project Creator : anthonyreilly
License : MIT License
Project Creator : anthonyreilly
protected override Expression Visit(Expression expression)
{
if (expression != null)
{
var saveCannotBeEvaluated = this.cannotBeEvaluated;
this.cannotBeEvaluated = false;
base.Visit(expression);
if (!this.cannotBeEvaluated)
{
if (this.fnCanBeEvaluated(expression))
{
this.candidates.Add(expression);
}
else
{
this.cannotBeEvaluated = true;
}
}
this.cannotBeEvaluated |= saveCannotBeEvaluated;
}
return expression;
}
See More Examples