views:

155

answers:

1

Hi, I am trying to write a simple activity that received from the user its name and printing "hello + username" message.

the problem is that i cannot access to the username input via code.

the function is:

static ActivityBuilder CreateTask1()
    {
        Dictionary<string, object> properties = new Dictionary<string, object>();
        properties.Add("User_Name", new InArgument<string>());

        var res = new ActivityBuilder();

        res.Name = "Task1";

        foreach (var item in properties)
        {
            res.Properties.Add(new DynamicActivityProperty { Name = item.Key, Type = item.Value.GetType(), Value = item.Value });
        }

        Sequence c = new Sequence();

        c.Activities.Add(new WriteLine { Text = "Hello " + properties["User_Name"] });

        res.Implementation = c;

        return res;
    }

The output of the followed will always be "Hello User_Name".

Thanks!

A: 

OK I have found the answer (and the new magical "VisualBasicValue" class):

static ActivityBuilder CreateTask1()
    {
        Dictionary<string, object> properties = new Dictionary<string, object>();
        properties.Add("User_Name", new InArgument<string>());

        var res = new ActivityBuilder();

        res.Name = "Task1";

        foreach (var item in properties)
        {
            res.Properties.Add(new DynamicActivityProperty { Name = item.Key, Type = item.Value.GetType(), Value = item.Value });
        }

        Sequence c = new Sequence();

        c.Activities.Add(new WriteLine { Text = new VisualBasicValue<string> { ExpressionText = "\"Hello \" + User_Name" } });

        res.Implementation = c;

        return res;
    }
Avi K.