ExpressionServices.ConvertReference<TResult> 메서드

정의

워크플로 환경 인식 식에 대한 참조를 작업 트리로 변환합니다.

public:
generic <typename TResult>
 static System::Activities::Activity<System::Activities::Location<TResult> ^> ^ ConvertReference(System::Linq::Expressions::Expression<Func<System::Activities::ActivityContext ^, TResult> ^> ^ expression);
public static System.Activities.Activity<System.Activities.Location<TResult>> ConvertReference<TResult>(System.Linq.Expressions.Expression<Func<System.Activities.ActivityContext,TResult>> expression);
static member ConvertReference : System.Linq.Expressions.Expression<Func<System.Activities.ActivityContext, 'Result>> -> System.Activities.Activity<System.Activities.Location<'Result>>
Public Shared Function ConvertReference(Of TResult) (expression As Expression(Of Func(Of ActivityContext, TResult))) As Activity(Of Location(Of TResult))

형식 매개 변수

TResult

식을 변환할 형식입니다.

매개 변수

expression
Expression<Func<ActivityContext,TResult>>

변환되는 식입니다.

반품

Activity<Location<TResult>>

변환된 식입니다.

예제

다음 두 코드 예제에서는 사용 ConvertReferenceConvert. 첫 번째 코드 예제에서는 작업에서 Assign 람다 식을 값이 할당된 문자열 속성으로 변환하는 데 사용됩니다ConvertReference. 다음으로, Convert 람다 식을 활동의 콘솔 WriteLine 에 인쇄되는 문자열 속성 값으로 변환하기 위해 호출됩니다.

// Define a struct with a property named AProperty.
struct StructWithProperty
{
    public string AProperty { get; set; }
}

public static void ConvertReferenceForValueTypePropertyReferenceSample()
{
    // Create a variable of type StructWithProperty to store the property.
    var swpvar = new Variable<StructWithProperty>("swpvar", new StructWithProperty());

    Activity myActivity = new Sequence
    {
        Variables = { swpvar },
        Activities =
        {
            // Create an Assign activity to assign a value to the AProperty property.
            new Assign<string>
            {
                To = ExpressionServices.ConvertReference<string>(ctx => swpvar.Get(ctx).AProperty),
                // Assign a string literal to AProperty.
                Value = "Hello",
            },
            // Print the new property value to the console.
            new WriteLine()
            {
                Text = ExpressionServices.Convert<string>(ctx => swpvar.Get(ctx).AProperty),
            }
        }
    };

    // Invoke the Sequence activity.
    WorkflowInvoker.Invoke(myActivity);
}

다음 코드 예제는 변환할 식이 다차원 배열의 항목에 대한 참조라는 점을 제외하고 이전 코드 예제와 같습니다.

public static void ConvertReferenceForMultidimensionalArrayItemReferenceSample()
{
    // Create a variable to store a multidimensional array.
    var arrayvar = new Variable<int[,]>("arrayvar", new int[4, 5]);

    Activity myActivity = new Sequence
    {
        Variables = { arrayvar },
        Activities =
        {
            // Create an Assign activity to assign a value to the array item at index [1,2].
            new Assign<int>
            {
                To = ExpressionServices.ConvertReference<int>(ctx => arrayvar.Get(ctx)[1, 2]),
                // Assign an integer value to the array item at row 1 column 2.
                Value = 1,
            },
            // Print the array item value to the console.
            new WriteLine()
            {
                Text = ExpressionServices.Convert<string>(ctx => arrayvar.Get(ctx)[1, 2].ToString()),
            }
        }
    };

    // Invoke the Sequence activity.
    WorkflowInvoker.Invoke(myActivity);
}

설명

변환 메서드 ExpressionServices 는 워크플로 내에서 정의되거나 인수를 통해 워크플로에 전달되는 변수 및 상수와 함께 작동하도록 설계되었습니다.

적용 대상