Skip to content
This repository has been archived by the owner on Mar 20, 2019. It is now read-only.

Commit

Permalink
More CC
Browse files Browse the repository at this point in the history
  • Loading branch information
AArnott committed Jun 26, 2009
1 parent b3c8561 commit 8958434
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
43 changes: 43 additions & 0 deletions src/DotNetOpenAuth/Messaging/Reflection/IMessagePartEncoder.cs
Expand Up @@ -7,6 +7,7 @@
namespace DotNetOpenAuth.Messaging.Reflection {
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;

Expand All @@ -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.
Expand All @@ -32,4 +34,45 @@ public interface IMessagePartEncoder {
/// <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
}
}
Expand Up @@ -78,7 +78,6 @@ internal class MessageDescriptionCollection {
[Pure]
internal MessageDictionary GetAccessor(IMessage message) {
Contract.Requires<ArgumentNullException>(message != null);
ErrorUtilities.VerifyArgumentNotNull(message, "message");
return this.Get(message).GetDictionary(message);
}

Expand Down

0 comments on commit 8958434

Please sign in to comment.