[WF4]A sample of IActivityTemplateFactory

By default, in WF4, we have a ReceiveAndSendReply activity in Toolbox. But we cannot find such a ReceiveAndSendReply class in .net Reflector.

So, where comes the ReceiveAndSendReply activity? yes, it is the magic feature of IActivityTemplateFactory. We can use this class as a composite activity wrapper. See sample:

    public class IActivityTemplateTest:IActivityTemplateFactory {
public Activity Create(System.Windows.DependencyObject target) {
            return new Delay {
                DisplayName = "My Delay",
Duration = TimeSpan.FromSeconds(5)


Build project, and we will find IActivityTemplateTest activity in the toolbox:

And we can drag this activity to workflow directly.

That is all.



blog comments powered by Disqus