//-----------------------------------------------------------------------
//
// Copyright (c) Outercurve Foundation. All rights reserved.
//
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.Messaging.Reflection {
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
///
/// An interface describing how various objects can be serialized and deserialized between their object and string forms.
///
///
/// Implementations of this interface must include a default constructor and must be thread-safe.
///
[ContractClass(typeof(IMessagePartEncoderContract))]
public interface IMessagePartEncoder {
///
/// Encodes the specified value.
///
/// The value. Guaranteed to never be null.
/// The in string form, ready for message transport.
string Encode(object value);
///
/// Decodes the specified value.
///
/// The string value carried by the transport. Guaranteed to never be null, although it may be empty.
/// The deserialized form of the given string.
/// Thrown when the string value given cannot be decoded into the required object type.
object Decode(string value);
}
///
/// Code contract for the type.
///
[ContractClassFor(typeof(IMessagePartEncoder))]
internal abstract class IMessagePartEncoderContract : IMessagePartEncoder {
///
/// Initializes a new instance of the class.
///
protected IMessagePartEncoderContract() {
}
#region IMessagePartEncoder Members
///
/// Encodes the specified value.
///
/// The value. Guaranteed to never be null.
///
/// The in string form, ready for message transport.
///
string IMessagePartEncoder.Encode(object value) {
Requires.NotNull(value, "value");
throw new NotImplementedException();
}
///
/// Decodes the specified value.
///
/// The string value carried by the transport. Guaranteed to never be null, although it may be empty.
///
/// The deserialized form of the given string.
///
/// Thrown when the string value given cannot be decoded into the required object type.
object IMessagePartEncoder.Decode(string value) {
Requires.NotNull(value, "value");
throw new NotImplementedException();
}
#endregion
}
}