Interop with 3.5 Rule Set

This topic applies to Windows Workflow Foundation 4 (WF4).

This sample demonstrates the use of the Interop activity to integrate with a custom activity in .NET Framework 3.5 using Policy and rules. It passes data to the custom activity by binding .NET Framework version 4 variables to the dependency properties exposed by the custom activity.

Requirements

  1. Visual Studio 2010

  2. .NET Framework version 4

  3. .NET Framework version 3.5

Demonstrates

Interop activity, Policy activity in .NET Framework 3.5 with dependency properties

Discussion

The sample demonstrates one of the integration scenarios for integrating with a .NET Framework 3.5 activity. This sample includes a .NET Framework 3.5 custom activity that invokes a Policy activity.

TravelRuleLibrary

Opening TravelRuleSet.cs in the designer shows a custom sequential activity that contains a Policy activity as follows

Interop Activity

Double-click the DiscountPolicy policy activity to examine the rules. The Rules editor appears to show the rules.

Rule Set Editor

Right-click the DiscountPolicy activity and select the View Code option to examine the code-beside C# code that goes with this activity. Observe the dependency property setting for DiscountLevel. This is equivalent to an Argument in .NET Framework 4.

public static DependencyProperty DiscountLevelProperty = DependencyProperty.Register("DiscountLevel", typeof(int), typeof(TravelRuleSet));

[DescriptionAttribute("DiscountLevel")]
[CategoryAttribute("DiscountLevel Category")]
[BrowsableAttribute(true)]
[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
public int DiscountLevel
{
   get
   {
return ((int)base.GetValue(TravelRuleSet.DiscountLevelProperty)));
   }
   set
   {
base.SetValue(TravelRuleSet.DiscountLevelProperty, value);
   }
}

InteropWith35RuleSet

This is a .NET Framework 4 sequential workflow project that uses the Interop activity to integrate with the custom rule set created in the TravelRuleLibrary project. Variables are created on the top-level Sequence as follows.

Variables

Solution Explorer

Lastly, the Interop activity is used to integrate with the TravelRuleSet. The variables that were declared earlier on the Sequence are used to bind to the dependency properties.

Activity Type

Arrow

Properties

Ee829487.Important(en-us,VS.100).gif Note:
The samples may already be installed on your computer. Check for the following (default) directory before continuing.

<InstallDrive>:\WF_WCF_Samples

If this directory does not exist, go to Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) Samples for .NET Framework 4 to download all Windows Communication Foundation (WCF) and WF samples. This sample is located in the following directory.

<InstallDrive>:\WF_WCF_Samples\WF\Basic\Built-InActivities\InteropWith35RuleSet