Detecting the language (C# or VB) of a host Workflow

87 Views Asked by At

I'm developing a custom activity which internally (in my activity designer) has a instruction using the code activity VisualBasicValue<string[]> which I use to represent an array of strings, e.g: { "a", "b", "c" }

However, in workflow projects written in C#, we need use CSharpValue<string[]> instead of VisualBasicValue<string[]>, and write the expression as: new [] { "a", "b", "c" }

How can I determine which language is set in my host workflow so I can choose the right code activity?

I read that C# projects has the attribute/node sap2010:ExpressionActivityEditor.ExpressionActivityEditor="C#" in the workflow but I don't know how to get this info from an activity design, I don't know if this is the best approach either.

Summing up, what I'm looking for is something that allow me to do this kind of logic:

CodeActivity<string[]> code = null;

if (__some_way_to_know_if_is_CSharp__)
{
    code = new CSharpValue<string[]> {
        ExpressionText = "new [] { 'a', 'b', 'c' }"
    }
}
else
{
    code = new VisualBasicValue<string[]> {
        ExpressionText = "{ 'a', 'b', 'c' }"
    }
}

ModelItem.Properties["Items"].SetValue(new InArgument<IEnumerable<string>>(code))

Thank you!

0

There are 0 best solutions below