Dil

GotoExpression Sınıf

Tanım

Koşulsuz bir atlamayı temsil eder. Buna dönüş deyimleri, kesme ve devam deyimleri ve diğer atlamalar dahildir.

public ref class GotoExpression sealed : System::Linq::Expressions::Expression
public sealed class GotoExpression : System.Linq.Expressions.Expression
type GotoExpression = class
    inherit Expression
Public NotInheritable Class GotoExpression
Inherits Expression
Devralma
GotoExpression

Örnekler

Aşağıdaki örnekte yöntemini kullanarak nesne içeren bir GotoExpression ifadenin nasıl oluşturulacağı gösterilmektedir Goto .

// Add the following directive to your file:
// using System.Linq.Expressions;

// A label expression of the void type that is the target for the GotoExpression.
LabelTarget returnTarget = Expression.Label();

// This block contains a GotoExpression.
// It transfers execution to a label expression that is initialized with the same LabelTarget as the GotoExpression.
// The types of the GotoExpression, label expression, and LabelTarget must match.
BlockExpression blockExpr =
    Expression.Block(
        Expression.Call(typeof(Console).GetMethod("WriteLine", new Type[] { typeof(string) }), Expression.Constant("GoTo")),
        Expression.Goto(returnTarget),
        Expression.Call(typeof(Console).GetMethod("WriteLine", new Type[] { typeof(string) }), Expression.Constant("Other Work")),
        Expression.Label(returnTarget)
    );

// The following statement first creates an expression tree,
// then compiles it, and then runs it.
Expression.Lambda<Action>(blockExpr).Compile()();

// This code example produces the following output:
//
// GoTo

// "Other Work" is not printed because
// the GoTo expression transfers execution from Expression.GoTo(returnTarget)
// to Expression.Label(returnTarget).
' Add the following directive to your file:
' Imports System.Linq.Expressions  

' A label expression of the void type that is the target for the GoToExpression.
Dim returnTarget As LabelTarget = Expression.Label()

' This block contains a GotoExpression.
' It transfers execution to a label expression that is initialized with the same LabelTarget as the GotoExpression.
' The types of the GotoExpression, label expression, and LabelTarget must match.
Dim blockExpr As BlockExpression =
      Expression.Block(
          Expression.Call(GetType(Console).GetMethod("WriteLine", New Type() {GetType(String)}), Expression.Constant("GoTo")),
          Expression.Goto(returnTarget),
          Expression.Call(GetType(Console).GetMethod("WriteLine", New Type() {GetType(String)}), Expression.Constant("Other Work")),
          Expression.Label(returnTarget)
      )

' The following statement first creates an expression tree,
' then compiles it, and then runs it.
Expression.Lambda(Of Action)(blockExpr).Compile()()

' This code example produces the following output:
'
' GoTo

' "Other Work" is not printed because 
' the Return expression transfers execution from Expression.GoTo(returnTarget)
' to Expression.Label(returnTarget).

Özellikler

Name Description
CanReduce

Düğümün daha basit bir düğüme indirgenebileceğini gösterir. Bu true döndürürse, azaltılmış formu oluşturmak için Reduce() çağrılabilir.

(Devralındığı yer: Expression)
Kind

"Git" ifadesinin türü. Yalnızca bilgi amaçlıdır.

NodeType

Bu Expressiondüğüm türünü döndürür.

Target

Bu düğümün atladığı hedef etiket.

Type

Bu Expression temsil ettiği ifadenin statik türünü alır.

Value

Hedefe geçirilen değer veya hedef System.Void türündeyse null.

Yöntemler

Name Description
Accept(ExpressionVisitor)

Bu düğüm türü için belirli bir ziyaret yöntemine gönderilir. Örneğin, MethodCallExpressionVisitMethodCall(MethodCallExpression)çağırır.

(Devralındığı yer: Expression)
Equals(Object)

Belirtilen nesnenin geçerli nesneye eşit olup olmadığını belirler.

(Devralındığı yer: Object)
GetHashCode()

Varsayılan karma işlevi işlevi görür.

(Devralındığı yer: Object)
GetType()

Geçerli örneğin Type alır.

(Devralındığı yer: Object)
MemberwiseClone()

Geçerli Objectbasit bir kopyasını oluşturur.

(Devralındığı yer: Object)
Reduce()

Bu düğümü daha basit bir ifadeye küçültür. CanReduce true döndürürse, bu geçerli bir ifade döndürmelidir. Bu yöntem, azaltması gereken başka bir düğüm döndürebilir.

(Devralındığı yer: Expression)
ReduceAndCheck()

Bu düğümü daha basit bir ifadeye küçültür. CanReduce true döndürürse, bu geçerli bir ifade döndürmelidir. Bu yöntem, azaltması gereken başka bir düğüm döndürebilir.

(Devralındığı yer: Expression)
ReduceExtensions()

İfadeyi bilinen bir düğüm türüne (Uzantı düğümü değildir) küçültür veya zaten bilinen bir türse yalnızca ifadeyi döndürür.

(Devralındığı yer: Expression)
ToString()

Expressionmetinsel gösterimini döndürür.

(Devralındığı yer: Expression)
Update(LabelTarget, Expression)

Bunun gibi, ancak sağlanan alt öğeleri kullanarak yeni bir ifade oluşturur. Tüm alt öğeler aynıysa, bu ifadeyi döndürür.

VisitChildren(ExpressionVisitor)

Düğümü azaltır ve ardından azaltılmış ifadede ziyaretçi temsilcisini çağırır. Yöntem, düğüm azaltılabilir değilse bir özel durum oluşturur.

(Devralındığı yer: Expression)

Şunlara uygulanır