WF 4 中的活动重新托管设计师 [英] While activity in WF 4 rehosted designer

查看:17
本文介绍了WF 4 中的活动重新托管设计师的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个自定义活动,其中包含一个简单的 ExpressionTextBox:

I have written a custom activity which contains a simple ExpressionTextBox:

       <sapv:ExpressionTextBox HintText="List of Strings" 
        Grid.Row ="0" Grid.Column="1" MaxWidth="150" MinWidth="150" Margin="5"
        OwnerActivity="{Binding Path=ModelItem}"
        Expression="{Binding Path=ModelItem.Test, Mode=TwoWay, 
            Converter={StaticResource ArgumentToExpressionConverter}, 
            ConverterParameter=In }" />

在库中,我添加了 Test 属性如下:

In the library, i've added Test property as follows:

       public InArgument<string> Test { get; set; }

所以,这就是整件事:

while 和在其作用域中定义的类型 i 的变量 i.我希望得到Test1"、Test2"......等等,但我得到:

A while and a variable i of type i defined in its scope. I would expect to get back "Test1", "Test2" ... and so on, but instead i get :

因此,变量 i 被视为一个字符串,而不是解释为变量部分中定义的整数.我也用字符串类型的简单属性尝试过这个.然后我想 InArgument 可能会处理这件事..我不知道该怎么做.有什么线索吗?

So, that variable i is seen as a string and not interpreted as the integer defined in the variables section. I've tried this with a simple property of type string also. Then i thought that InArgument might handle the thing.. i don't know what to do more. Any clues about this?

推荐答案

我可能需要将您的更多代码发布到 bb 来帮助更多,并完全了解您想要实现的目标.但是从屏幕截图中我可以看到您没有访问缓存元数据方法中的运行时参数.随后,您正在调用的控制台 writeline 方法将解释原始文本值,而不是正确评估表达式.

I might need more of your code posting to bb able to help more, and understand fully what you want to achieve. But from the screen shot I can see that your not accessing the Runtime Arguments in the cache meta data method. Subsequently the console writeline method you are calling is interpreting the raw text value rather than correctly evaluating the expression.

在您的代码活动中尝试以下操作

Try the following in your code activity

using System; 
using System.ComponentModel; 
using System.IO;
using System.Runtime; 
using System.Activities.Validation;
using System.Collections.Generic;
using System.Windows.Markup;
using System.Collections.ObjectModel;
using System.Activities; 

namespace WorkflowConsoleApplication2
{

    public sealed class CodeActivity1 : CodeActivity
    {
        // Define an activity input argument of type string
        [DefaultValue(null)]
        public InArgument<string> Test
        {
            get;
            set;
        }

        protected override void CacheMetadata(CodeActivityMetadata metadata)
        {
            RuntimeArgument textArgument = new RuntimeArgument("Test",    typeof(string), ArgumentDirection.In);
            metadata.Bind(this.Test, textArgument);


            metadata.SetArgumentsCollection(
            new Collection<RuntimeArgument> 
            {
                textArgument,
            });
        }

        // If your activity returns a value, derive from CodeActivity<TResult>
        // and return the value from the Execute method.
        protected override void Execute(CodeActivityContext context)
        {
            Console.WriteLine(this.Test.Get(context)); 
        }
}

}

这篇关于WF 4 中的活动重新托管设计师的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆