//----------------------------------------------------------------------- // // Copyright (c) Andrew Arnott. All rights reserved. // //----------------------------------------------------------------------- namespace DotNetOpenAuth.BuildTasks { using Microsoft.Build.Framework; using Microsoft.Build.Utilities; /// /// Trims item identities. /// public class Trim : Task { /// /// Gets or sets the characters that should be trimmed off if found at the start of items' ItemSpecs. /// public string StartCharacters { get; set; } /// /// Gets or sets the characters that should be trimmed off if found at the end of items' ItemSpecs. /// public string EndCharacters { get; set; } /// /// Gets or sets the items with ItemSpec's to be trimmed. /// [Required] public ITaskItem[] Inputs { get; set; } /// /// Gets or sets the items with trimmed ItemSpec strings. /// [Output] public ITaskItem[] Outputs { get; set; } /// /// Executes this instance. /// /// A value indicating whether the task completed successfully. public override bool Execute() { this.Outputs = new ITaskItem[this.Inputs.Length]; for (int i = 0; i < this.Inputs.Length; i++) { this.Outputs[i] = new TaskItem(this.Inputs[i]); if (!string.IsNullOrEmpty(this.StartCharacters)) { this.Outputs[i].ItemSpec = this.Outputs[i].ItemSpec.TrimStart(this.StartCharacters.ToCharArray()); } if (!string.IsNullOrEmpty(this.EndCharacters)) { this.Outputs[i].ItemSpec = this.Outputs[i].ItemSpec.TrimEnd(this.EndCharacters.ToCharArray()); } } return true; } } }