本文整理汇总了C#中IExpression.Accept方法的典型用法代码示例。如果您正苦于以下问题:C# IExpression.Accept方法的具体用法?C# IExpression.Accept怎么用?C# IExpression.Accept使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IExpression
的用法示例。
在下文中一共展示了IExpression.Accept方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compile
public void Compile(IExpression expression)
{
Require.NotNull(expression, "expression");
expression.Accept(new Visitor(this));
if (
(expression.Type.IsValueType || _resolver.Options.ResultType.IsValueType) &&
expression.Type != _resolver.Options.ResultType
) {
try
{
ExtendedConvertToType(expression.Type, _resolver.Options.ResultType, true);
}
catch (Exception ex)
{
throw new ExpressionsException("Cannot convert expression result to expected result type", ExpressionsExceptionType.InvalidExplicitCast, ex);
}
_il.Emit(OpCodes.Box, _resolver.Options.ResultType);
}
else if (expression.Type.IsValueType)
{
_il.Emit(OpCodes.Box, expression.Type);
}
else if (!_resolver.Options.ResultType.IsAssignableFrom(expression.Type))
{
throw new ExpressionsException("Cannot convert expression result to expected result type", ExpressionsExceptionType.TypeMismatch);
}
_il.Emit(OpCodes.Ret);
}
示例2: InjectOptimization
public virtual void InjectOptimization(IExpression expr)
{
_editor.AddInterface(TypeRef(typeof (IDb4oEnhancedFilter)));
_builder = _editor.NewPublicMethod(PlatformName(OptimizeQueryMethodName), TypeRef
(typeof (void)), new[] {TypeRef(typeof (IQuery))});
var predicateClass = _editor.Type;
expr.Accept(new SODAExpressionBuilder(this, predicateClass));
_builder.Pop();
_builder.EndMethod();
}
示例3: FlattenConcatArguments
private void FlattenConcatArguments(List<IExpression> arguments, IExpression argument)
{
var binaryExpression = argument as BinaryExpression;
if (
binaryExpression != null &&
binaryExpression.ExpressionType == ExpressionType.Add
)
{
FlattenConcatArguments(arguments, binaryExpression.Left);
FlattenConcatArguments(arguments, binaryExpression.Right);
}
else
{
arguments.Add(argument.Accept(this));
}
}
示例4: Emit
private void Emit(IExpression expression, Type type)
{
expression.Accept(this);
if (expression.Type != type)
_compiler.ExtendedConvertToType(expression.Type, type, false);
}
示例5: OptimizeQuery
public virtual void OptimizeQuery(IExpression expr, IQuery query, object predicate
, INativeClassFactory classSource, IReferenceResolver referenceResolver)
{
expr.Accept(new SODAQueryBuilder.SODAQueryVisitor(query, predicate, classSource,
referenceResolver));
}