Skip to content

Instantly share code, notes, and snippets.

@Nilzor
Created November 25, 2011 10:17
Show Gist options
  • Save Nilzor/1393205 to your computer and use it in GitHub Desktop.
Save Nilzor/1393205 to your computer and use it in GitHub Desktop.
DynamicSalutationRulesActivity - WF4 dynamic activity
/// <summary>
/// Translates a "MyRule" object to a Sequence of If-Then-Assign-Actions
/// </summary>
public class DynamicSalutationRulesActivity : Activity
{
public InArgument<Person> Person { get; set; }
public DynamicSalutationRulesActivity(List<SalutationAssignmentRule> rules)
{
Common.AddVbSetting(this);
var sequence = new Sequence();
this.Implementation = () => sequence;
// Sort descending - those added first are lowest priority
var sortedRules = rules.OrderByDescending(p => p.Priority).ToList();
// Convert to if-activities and add to sequence
foreach (var inRule in sortedRules)
{
var outRule = RuleConverter.ToIfActivity(inRule);
sequence.Activities.Add(outRule);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment