1: using Microsoft.Build.Utilities;
2: using Microsoft.Build.Framework;
3: using System.Collections.Generic;
4: using System.Text;
5: namespace ElBruno.TfsBuild
6: {
7: public class StringConcatenate : Task
8: {
9: #region TFS Task Properties
10: /// <summary>
11: /// Gets or sets the separator.
12: /// </summary>
13: /// <value>The separator.</value>
14: public string Separator { get; set; }
15: /// <summary>
16: /// Gets or sets a value indicating whether [append line].
17: /// </summary>
18: /// <value><c>true</c> if [append line]; otherwise, <c>false</c>.</value>
19: public bool AppendLine { get; set; }
20: /// <summary>
21: /// Gets or sets the items.
22: /// </summary>
23: /// <value>The items.</value>
24: public ITaskItem[] Items { get; set; }
25: /// <summary>
26: /// Gets or sets the string result.
27: /// </summary>
28: /// <value>The string result.</value>
29: [Output]
30: public string StringResult { get; set; }
31: #endregion
32:
33: #region TFS Override members
34: /// <summary>
35: /// Executes this instance.
36: /// </summary>
37: /// <returns></returns>
38: public override bool Execute()
39: {
40: bool ret = true;
41: var sb = new StringBuilder();
42: if (Items != null)
43: {
44: for (int i = 0; i < Items.Length; i++)
45: {
46: sb.Append(Items[i].ItemSpec);
47: if (i < Items.Length - 1)
48: {
49: sb.Append(Separator);
50: if (AppendLine)
51: sb.AppendLine();
52: }
53: }
54: }
55: StringResult = sb.ToString();
56: return ret;
57: }
58: #endregion
59: }
60: }