다음을 통해 공유


DynamicActivity.Implementation 속성

정의

활동의 실행 논리를 가져오거나 설정합니다.

public:
 property Func<System::Activities::Activity ^> ^ Implementation { Func<System::Activities::Activity ^> ^ get(); void set(Func<System::Activities::Activity ^> ^ value); };
[System.ComponentModel.Browsable(false)]
[System.Windows.Markup.Ambient]
[System.Windows.Markup.XamlDeferLoad(typeof(System.Activities.XamlIntegration.FuncDeferringLoader), typeof(System.Activities.Activity))]
public Func<System.Activities.Activity> Implementation { get; set; }
[<System.ComponentModel.Browsable(false)>]
[<System.Windows.Markup.Ambient>]
[<System.Windows.Markup.XamlDeferLoad(typeof(System.Activities.XamlIntegration.FuncDeferringLoader), typeof(System.Activities.Activity))>]
member this.Implementation : Func<System.Activities.Activity> with get, set
Public Property Implementation As Func(Of Activity)

속성 값

실행 논리입니다.

특성

예제

다음 예제에서는 동적 활동에 대한 구현을 지정하는 방법을 보여 줍니다.

// Variables
var iterationVariable = new DelegateInArgument<int>() { Name = "iterationVariable" };
var accumulator = new Variable<int>() { Default = 0, Name = "accumulator" };

// Define the Input and Output arguments that the DynamicActivity binds to
var numbers = new InArgument<List<int>>();
var average = new OutArgument<double>();

var result = new Variable<double>() { Name = "result" };

return new DynamicActivity()
{
    DisplayName = "Find average",
    Properties =
    {
        // Input argument
        new DynamicActivityProperty
        {
            Name = "Numbers",
            Type = typeof(InArgument<List<int>>),
            Value = numbers
        },
        // Output argument
        new DynamicActivityProperty
        {
            Name = "Average",
            Type = typeof(OutArgument<double>),
            Value = average
        }
    },
    Implementation = () =>
        new Sequence
        {
            Variables = { result, accumulator },
            Activities =
            {
                new ForEach<int>
                {
                    Values =  new ArgumentValue<IEnumerable<int>> { ArgumentName = "Numbers" },
                    Body = new ActivityAction<int>
                    {
                        Argument = iterationVariable,
                        Handler = new Assign<int>
                        {
                            To = accumulator,
                            Value = new InArgument<int>(env => iterationVariable.Get(env) +  accumulator.Get(env))
                        }
                    }
                },

                // Calculate the average and assign to the output argument.
                new Assign<double>
                {
                    To = new ArgumentReference<double> { ArgumentName = "Average" },
                    Value = new InArgument<double>(env => accumulator.Get(env) / numbers.Get(env).Count<int>())
                },
            }
        }

적용 대상