Custom Action: retrieving strings property

I’m creating a custom action with C#.Net 2.0 passing in a “strings” property. I need to retrieve the individual values of this property within my C# code.

This code retrieves the strings but they aren’t a collection but rather a control line feed-delimited string. How can I retrieve the individual strings? Do I need to parse/split the IFBString object in C#?



IFBStrings systems = Context.Properties.get_PropertyAsStrings(“Systems”);

for (int i=0; i < this.systems.Count; i++)
{
string system = Context.ExpandExpression(this.starTeamSystems.get_Strings(i), true);
}


Thanks.

Hi Jeff,

The code that you quote above should reead each individual entry in the FBStrings object. Are you just seeing one large string (at index 0?)

I’ll see if we can add IEnumerable support to the FBStrings interface for the next major release. Hopefully this will let you use the FBStrings objects more like a collection (‘foreach’, etc.)

- Angus

IEnumerable would be great. For now, let me provide a bit more background…perhaps I’m making a mistake when populating or passing the property.

I have a “Prompt for Variables (Enhanced)” action which presents a “Check List” control of systems (projects) to be choosen. I persist the items checked in a variable. I then pass this variable into a Custom Action using a “strings” type property.

Inside C#, the property is a control-line-feed-delimited string as opposed to some sort of collection. As a work-around, I’m using the following code to split the string elements into an array:

IFBStrings systemsProperty = Context.Properties.get_PropertyAsStrings(“Systems”);

string systemsString = Context.ExpandExpression(systemsProperty.get_Strings(0), false);

string[] systems = systemsString.Split(new Char[] { ‘\n’ });

Hi Jeff,

This is because the Prompt For Variables (enhanced) sets the variable as a string (not a list of strings). Plus, your action is exposing a field that you’re putting the name of the variable in so you can expand it during execution - and for this you only require a property of type “string”. So, you’re workaround is the way you need to do it (with the exception that you could change the property to a string type instead of strings).

hth.
.t8