summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.BuildTasks/Trim.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2009-09-01 17:34:59 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2009-09-01 17:34:59 -0700
commit6e8a6eb02294c28b13bacaa339e58a67fd766f99 (patch)
treea1bd58a2a51505ba71b697fb61378e7142df8ef3 /src/DotNetOpenAuth.BuildTasks/Trim.cs
parente36299f39476c56977c39700067ed8f6ae0a4e49 (diff)
parent36b1ba3c75d060fa71f6f15582b90e7f70292ddc (diff)
downloadDotNetOpenAuth-6e8a6eb02294c28b13bacaa339e58a67fd766f99.zip
DotNetOpenAuth-6e8a6eb02294c28b13bacaa339e58a67fd766f99.tar.gz
DotNetOpenAuth-6e8a6eb02294c28b13bacaa339e58a67fd766f99.tar.bz2
Merge branch 'master' into contracts
Conflicts: src/DotNetOpenAuth.Test/Mocks/MockIdentifier.cs src/DotNetOpenAuth.Test/OpenId/Provider/OpenIdProviderTests.cs src/DotNetOpenAuth.vsmdi src/DotNetOpenAuth/DotNetOpenAuth.csproj src/DotNetOpenAuth/Messaging/MessageReceivingEndpoint.cs src/DotNetOpenAuth/OAuth/ChannelElements/OAuthServiceProviderMessageFactory.cs src/DotNetOpenAuth/OAuth/Protocol.cs src/DotNetOpenAuth/OAuth/ServiceProvider.cs src/DotNetOpenAuth/OpenId/Association.cs src/DotNetOpenAuth/OpenId/Behaviors/PpidGeneration.cs src/DotNetOpenAuth/OpenId/NoDiscoveryIdentifier.cs src/DotNetOpenAuth/OpenId/Provider/HostProcessedRequest.cs src/DotNetOpenAuth/OpenId/Provider/IDirectedIdentityIdentifierProvider.cs src/DotNetOpenAuth/OpenId/Provider/PrivatePersonalIdentifierProviderBase.cs src/DotNetOpenAuth/OpenId/Realm.cs src/DotNetOpenAuth/OpenId/RelyingParty/AuthenticationRequest.cs src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdAjaxTextBox.cs src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdRelyingPartyAjaxControlBase.cs src/DotNetOpenAuth/OpenId/RelyingParty/OpenIdTextBox.cs src/DotNetOpenAuth/OpenId/RelyingParty/PositiveAuthenticationResponseSnapshot.cs src/DotNetOpenAuth/OpenId/UriIdentifier.cs src/DotNetOpenAuth/OpenId/XriIdentifier.cs src/DotNetOpenAuth/Util.cs
Diffstat (limited to 'src/DotNetOpenAuth.BuildTasks/Trim.cs')
-rw-r--r--src/DotNetOpenAuth.BuildTasks/Trim.cs56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/DotNetOpenAuth.BuildTasks/Trim.cs b/src/DotNetOpenAuth.BuildTasks/Trim.cs
new file mode 100644
index 0000000..1cc943e
--- /dev/null
+++ b/src/DotNetOpenAuth.BuildTasks/Trim.cs
@@ -0,0 +1,56 @@
+//-----------------------------------------------------------------------
+// <copyright file="Trim.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOpenAuth.BuildTasks {
+ using Microsoft.Build.Framework;
+ using Microsoft.Build.Utilities;
+
+ /// <summary>
+ /// Trims item identities.
+ /// </summary>
+ public class Trim : Task {
+ /// <summary>
+ /// Gets or sets the characters that should be trimmed off if found at the start of items' ItemSpecs.
+ /// </summary>
+ public string StartCharacters { get; set; }
+
+ /// <summary>
+ /// Gets or sets the characters that should be trimmed off if found at the end of items' ItemSpecs.
+ /// </summary>
+ public string EndCharacters { get; set; }
+
+ /// <summary>
+ /// Gets or sets the items with ItemSpec's to be trimmed.
+ /// </summary>
+ [Required]
+ public ITaskItem[] Inputs { get; set; }
+
+ /// <summary>
+ /// Gets or sets the items with trimmed ItemSpec strings.
+ /// </summary>
+ [Output]
+ public ITaskItem[] Outputs { get; set; }
+
+ /// <summary>
+ /// Executes this instance.
+ /// </summary>
+ /// <returns>A value indicating whether the task completed successfully.</returns>
+ 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;
+ }
+ }
+}