diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2013-02-16 20:15:06 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2013-02-16 20:15:06 -0800 |
commit | fcee7171b683db63aafac3c7351b22a849d06db4 (patch) | |
tree | 69e98c2be1e4fb8d8496010ee6e45e5d19ac0a36 /src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/OAuthHttpMethodBindingElement.cs | |
parent | 04426dfbba325fd4ed308a6c9c6c103fed14ff13 (diff) | |
download | DotNetOpenAuth-fcee7171b683db63aafac3c7351b22a849d06db4.zip DotNetOpenAuth-fcee7171b683db63aafac3c7351b22a849d06db4.tar.gz DotNetOpenAuth-fcee7171b683db63aafac3c7351b22a849d06db4.tar.bz2 |
Lots of stylecop fixes.
Diffstat (limited to 'src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/OAuthHttpMethodBindingElement.cs')
-rw-r--r-- | src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/OAuthHttpMethodBindingElement.cs | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/OAuthHttpMethodBindingElement.cs b/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/OAuthHttpMethodBindingElement.cs index 67192ee..60df47f 100644 --- a/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/OAuthHttpMethodBindingElement.cs +++ b/src/DotNetOpenAuth.OAuth/OAuth/ChannelElements/OAuthHttpMethodBindingElement.cs @@ -17,6 +17,17 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { /// Sets the HTTP Method property on a signed message before the signing module gets to it. /// </summary> internal class OAuthHttpMethodBindingElement : IChannelBindingElement { + /// <summary> + /// A reusable pre-completed task that may be returned multiple times to reduce GC pressure. + /// </summary> + private static readonly Task<MessageProtections?> NullTask = Task.FromResult<MessageProtections?>(null); + + /// <summary> + /// A reusable pre-completed task that may be returned multiple times to reduce GC pressure. + /// </summary> + private static readonly Task<MessageProtections?> NoneTask = + Task.FromResult<MessageProtections?>(MessageProtections.None); + #region IChannelBindingElement Members /// <summary> @@ -40,20 +51,20 @@ namespace DotNetOpenAuth.OAuth.ChannelElements { /// True if the <paramref name="message"/> applied to this binding element /// and the operation was successful. False otherwise. /// </returns> - public async Task<MessageProtections?> ProcessOutgoingMessageAsync(IProtocolMessage message, CancellationToken cancellationToken) { + public Task<MessageProtections?> ProcessOutgoingMessageAsync(IProtocolMessage message, CancellationToken cancellationToken) { var oauthMessage = message as ITamperResistantOAuthMessage; if (oauthMessage != null) { HttpDeliveryMethods transmissionMethod = oauthMessage.HttpMethods; try { oauthMessage.HttpMethod = MessagingUtilities.GetHttpVerb(transmissionMethod); - return MessageProtections.None; + return NoneTask; } catch (ArgumentException ex) { Logger.OAuth.Error("Unrecognized HttpDeliveryMethods value.", ex); - return null; + return NullTask; } } else { - return null; + return NullTask; } } |