本文整理匯總了C#中System.Activities.DynamicActivity.Implementation屬性的典型用法代碼示例。如果您正苦於以下問題:C# DynamicActivity.Implementation屬性的具體用法?C# DynamicActivity.Implementation怎麽用?C# DynamicActivity.Implementation使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Activities.DynamicActivity
的用法示例。
在下文中一共展示了DynamicActivity.Implementation屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: DynamicActivity
// 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>())
},
}
}