【问题标题】:Deriving a workflow activity from native activity从本机活动派生工作流活动
【发布时间】:2014-09-18 22:37:07
【问题描述】:

我有一个从 NativeActivity 派生的名为“BaseActivity”的基类。我想在基类中拥有我所有的常见行为,并在派生类中使用它们。假设我在基类中有共同的输入/输出参数。我的派生类有自己的输入/输出参数。我的问题是,我怎样才能将一个输出参数从我的派生类传递给基类,以便基类输出参数将消息传递回客户端?

基础活动课

公共类 BaseActivity : NativeActivity { #region "公共参数列表" // 定义一个字符串类型的活动输入/输出参数 公共 InArgument FirstArgument{ 得到;放; } 公共 InArgument SecondArgument{ 得到;放; } 公共 OutArgument 结果 { 得到;放; }

public virtual NativeActivityContext PushContext(NativeActivityContext context, Dictionary DictBase) { 返回上下文; }

protected override void CacheMetadata(NativeActivityMetadata 元数据) { base.CacheMetadata(元数据);

    }

受保护的覆盖无效执行(NativeActivityContext 上下文) {

        // Read context variables to local string variables.

        string firstVal= context.GetValue(this.FirstArgument);
        string secondVal= context.GetValue(this.SecondArgument);

        string OutputResult = context.GetValue(this.Result);


        Dictionary<string, object> contextdictionary = new Dictionary<string, object>();
        contextdictionary.Add("first", firstVal);
        contextdictionary.Add("second", secondVal);

        contextdictionary.Add("output", OutputResult);




         NativeActivityContext finalContext = PushContext(context, contextdictionary);




    }

}

派生类

公共类子:BaseActivity { 公共 InArgument XsltPath { 获取;放; } 公共 OutArgument OutValue{ 获取;放; }

public override NativeActivityContext PushContext(NativeActivityContext context, Dictionary DictBase) { // 一些字符串操作,然后传递它。 OutValue.Set(context, outputStringBuilder.ToString());

        }



        return context;
    }

}

问题是如何将 OutValue 传递给基本活动输出参数。子活动中的值是正确的,但是当我调用工作流时,它返回一个空字符串。 pl。帮我。提前致谢。

【问题讨论】:

  • 您能否更新您的帖子以提供更好的格式?因为你的代码格式不正确

标签: workflow workflow-foundation-4


【解决方案1】:

您是否尝试将派生参数转发给基类?

public InArgument<string> XsltPath 
{ 
    get { return base.FirstArgument; } 
    set { base.FirstArgument = value; }
}
public OutArgument<string> OutValue
{
    get { return base.SecondArgument; } 
    set { base.SecondArgument = value; }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多