Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The StringCollection provides a way for users to enter a list of strings. In your code, you can refer to these strings as members of an array. To use this class, you must include a reference to the CodeSmith.CustomProperties assembly in your template:

Code Block
languagehtml/xml
<%@ Assembly Name="CodeSmith.CustomProperties" %>

After you include the appropriate assembly reference, you can define a property in a script block that uses the StringCollection

Code Block
languagehtml/xml
<%@ Property Name="List" Type="CodeSmith.CustomProperties.StringCollection" Category="Custom" Description="This is the list." %>

When the user executes the template, the specified property will display a builder button on the property sheet:

...

In your code, you can iterate through the collection as an array:

The list is:

Code Block
languagehtml/xml
<% for (int i = 0; i < List.Count; i++)\{ %>

...


<%= List[i] %>

...


<% \} %>