Expose NativeActivity Variables to Workflow Designer
Posted
by sixlettervariables
on Stack Overflow
See other posts from Stack Overflow
or by sixlettervariables
Published on 2010-06-09T22:00:48Z
Indexed on
2010/06/10
8:12 UTC
Read the original article
Hit count: 868
I've got a NativeActivity
which contains an Activity
body. The purpose of this activity is to expose a resource for the duration of the child activity as a Variable
. The problem I've encountered is it appears the Variable
cannot be used outside the activity. I'll use StreamReader
as an example resource.
ResourceActivity.cs:
[Designer(typeof(ResourceActivityDesigner))]
public sealed class ResourceActivity : NativeActivity
{
[RequiredArgument]
public InArgument<string> Path { get; set; }
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public Activity Body { get; set; }
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public Variable<StreamReader> Resource { get; set; }
public ResourceActivity()
{
this.Resource = new Variable<StreamReader>
{
Default = null,
Name = "reader"
};
}
protected override void CacheMetadata(NativeActivityMetadata metadata)
{
if (this.Path != null) metadata.AddArgument(this.Path);
if (this.Body != null) metadata.AddChild(this.Body);
if (this.Resource != null) metadata.AddVariable(this.Resource);
}
protected override void Execute(NativeActivityContext context)
{
this.Resource.Set(context, new StreamReader(this.Path.Get(context)));
context.ScheduleActivity(this.Body, new completionCallback(Done), new FaultCallback(Faulted));
}
private void Done(NativeActivityContext context, ActivityInstance instance)
{
var reader = this.Reader.Get(context);
if (reader != null) reader.Dispose();
}
private void Faulted(NativeActivityFaultContext context, Exception ex, ActivityInstance instance)
{
var reader = this.Reader.Get(context);
if (reader != null) reader.Dispose();
}
}
I cannot view "Resource" or "reader" in the Variables list in the Workflow Designer. Am I missing something in CacheMetadata
?
© Stack Overflow or respective owner