diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2009-06-26 07:27:26 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2009-06-26 07:27:26 -0700 |
commit | 89584345dac225523152fc74a17753898caaa258 (patch) | |
tree | 01df267391b10afef665715baa083e2362f89a3e /src | |
parent | b3c8561ac3a96ddf0c57b6fc2dbf0a3dbadacfc6 (diff) | |
download | DotNetOpenAuth-89584345dac225523152fc74a17753898caaa258.zip DotNetOpenAuth-89584345dac225523152fc74a17753898caaa258.tar.gz DotNetOpenAuth-89584345dac225523152fc74a17753898caaa258.tar.bz2 |
More CC
Diffstat (limited to 'src')
-rw-r--r-- | src/DotNetOpenAuth/Messaging/Reflection/IMessagePartEncoder.cs | 43 | ||||
-rw-r--r-- | src/DotNetOpenAuth/Messaging/Reflection/MessageDescriptionCollection.cs | 1 |
2 files changed, 43 insertions, 1 deletions
diff --git a/src/DotNetOpenAuth/Messaging/Reflection/IMessagePartEncoder.cs b/src/DotNetOpenAuth/Messaging/Reflection/IMessagePartEncoder.cs index d2c9596..03534f2 100644 --- a/src/DotNetOpenAuth/Messaging/Reflection/IMessagePartEncoder.cs +++ b/src/DotNetOpenAuth/Messaging/Reflection/IMessagePartEncoder.cs @@ -7,6 +7,7 @@ namespace DotNetOpenAuth.Messaging.Reflection { using System; using System.Collections.Generic; + using System.Diagnostics.Contracts; using System.Linq; using System.Text; @@ -16,6 +17,7 @@ namespace DotNetOpenAuth.Messaging.Reflection { /// <remarks> /// Implementations of this interface must include a default constructor and must be thread-safe. /// </remarks> + [ContractClass(typeof(IMessagePartEncoderContract))] public interface IMessagePartEncoder { /// <summary> /// Encodes the specified value. @@ -32,4 +34,45 @@ namespace DotNetOpenAuth.Messaging.Reflection { /// <exception cref="FormatException">Thrown when the string value given cannot be decoded into the required object type.</exception> object Decode(string value); } + + /// <summary> + /// Code contract for the <see cref="IMessagePartEncoder"/> type. + /// </summary> + [ContractClassFor(typeof(IMessagePartEncoder))] + internal abstract class IMessagePartEncoderContract : IMessagePartEncoder { + /// <summary> + /// Initializes a new instance of the <see cref="IMessagePartEncoderContract"/> class. + /// </summary> + protected IMessagePartEncoderContract() { + } + + #region IMessagePartEncoder Members + + /// <summary> + /// Encodes the specified value. + /// </summary> + /// <param name="value">The value. Guaranteed to never be null.</param> + /// <returns> + /// The <paramref name="value"/> in string form, ready for message transport. + /// </returns> + string IMessagePartEncoder.Encode(object value) { + Contract.Requires<ArgumentNullException>(value != null); + throw new NotImplementedException(); + } + + /// <summary> + /// Decodes the specified value. + /// </summary> + /// <param name="value">The string value carried by the transport. Guaranteed to never be null, although it may be empty.</param> + /// <returns> + /// The deserialized form of the given string. + /// </returns> + /// <exception cref="FormatException">Thrown when the string value given cannot be decoded into the required object type.</exception> + object IMessagePartEncoder.Decode(string value) { + Contract.Requires<ArgumentNullException>(value != null); + throw new NotImplementedException(); + } + + #endregion + } } diff --git a/src/DotNetOpenAuth/Messaging/Reflection/MessageDescriptionCollection.cs b/src/DotNetOpenAuth/Messaging/Reflection/MessageDescriptionCollection.cs index b01b03e..ff8b74b 100644 --- a/src/DotNetOpenAuth/Messaging/Reflection/MessageDescriptionCollection.cs +++ b/src/DotNetOpenAuth/Messaging/Reflection/MessageDescriptionCollection.cs @@ -78,7 +78,6 @@ namespace DotNetOpenAuth.Messaging.Reflection { [Pure] internal MessageDictionary GetAccessor(IMessage message) { Contract.Requires<ArgumentNullException>(message != null); - ErrorUtilities.VerifyArgumentNotNull(message, "message"); return this.Get(message).GetDictionary(message); } |