.NET Framework - 表达式树 - System.Linq.Expressions.Expression<TDelegate> 类 源码

创建时间:
2015-11-24 22:26
最近更新:
2018-10-23 14:43

Source Code of System.Linq.Expressions.Expression<TDelegate> from JetBrains dotPeek 1.0 at 2017-12-02

Complete Copy:

// Type: System.Linq.Expressions.Expression`1
// Assembly: System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// Assembly location: C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Core.dll

using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Dynamic.Utils;
using System.Linq.Expressions.Compiler;
using System.Runtime.CompilerServices;

namespace System.Linq.Expressions
{
  [__DynamicallyInvokable]
  public sealed class Expression<TDelegate> : LambdaExpression
  {
    internal Expression(Expression body, string name, bool tailCall, ReadOnlyCollection<ParameterExpression> parameters)
      : base(typeof (TDelegate), name, body, tailCall, parameters)
    {
    }

    [__DynamicallyInvokable]
    public TDelegate Compile()
    {
      return (TDelegate) LambdaCompiler.Compile((LambdaExpression) this, (DebugInfoGenerator) null);
    }

    public TDelegate Compile(DebugInfoGenerator debugInfoGenerator)
    {
      ContractUtils.RequiresNotNull((object) debugInfoGenerator, "debugInfoGenerator");
      return (TDelegate) LambdaCompiler.Compile((LambdaExpression) this, debugInfoGenerator);
    }

    [__DynamicallyInvokable]
    public Expression<TDelegate> Update(Expression body, IEnumerable<ParameterExpression> parameters)
    {
      if (body == this.Body && parameters == this.Parameters)
        return this;
      else
        return Expression.Lambda<TDelegate>(body, this.Name, this.TailCall, parameters);
    }

    protected internal override Expression Accept(ExpressionVisitor visitor)
    {
      return visitor.VisitLambda<TDelegate>(this);
    }

    internal override LambdaExpression Accept(StackSpiller spiller)
    {
      return (LambdaExpression) spiller.Rewrite<TDelegate>(this);
    }

    internal static LambdaExpression Create(Expression body, string name, bool tailCall, ReadOnlyCollection<ParameterExpression> parameters)
    {
      return (LambdaExpression) new Expression<TDelegate>(body, name, tailCall, parameters);
    }
  }
}