//-----------------------------------------------------------------------
//
// Copyright (c) Outercurve Foundation. All rights reserved.
//
//-----------------------------------------------------------------------
namespace DotNetOpenAuth.Messaging {
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
///
/// A tool to analyze an incoming message to figure out what concrete class
/// is designed to deserialize it and instantiates that class.
///
[ContractClass(typeof(IMessageFactoryContract))]
public interface IMessageFactory {
///
/// Analyzes an incoming request message payload to discover what kind of
/// message is embedded in it and returns the type, or null if no match is found.
///
/// The intended or actual recipient of the request message.
/// The name/value pairs that make up the message payload.
///
/// A newly instantiated -derived object that this message can
/// deserialize to. Null if the request isn't recognized as a valid protocol message.
///
IDirectedProtocolMessage GetNewRequestMessage(MessageReceivingEndpoint recipient, IDictionary fields);
///
/// Analyzes an incoming request message payload to discover what kind of
/// message is embedded in it and returns the type, or null if no match is found.
///
///
/// The message that was sent as a request that resulted in the response.
///
/// The name/value pairs that make up the message payload.
///
/// A newly instantiated -derived object that this message can
/// deserialize to. Null if the request isn't recognized as a valid protocol message.
///
IDirectResponseProtocolMessage GetNewResponseMessage(IDirectedProtocolMessage request, IDictionary fields);
}
///
/// Code contract for the interface.
///
[ContractClassFor(typeof(IMessageFactory))]
internal abstract class IMessageFactoryContract : IMessageFactory {
///
/// Prevents a default instance of the class from being created.
///
private IMessageFactoryContract() {
}
#region IMessageFactory Members
///
/// Analyzes an incoming request message payload to discover what kind of
/// message is embedded in it and returns the type, or null if no match is found.
///
/// The intended or actual recipient of the request message.
/// The name/value pairs that make up the message payload.
///
/// A newly instantiated -derived object that this message can
/// deserialize to. Null if the request isn't recognized as a valid protocol message.
///
IDirectedProtocolMessage IMessageFactory.GetNewRequestMessage(MessageReceivingEndpoint recipient, IDictionary fields) {
Requires.NotNull(recipient, "recipient");
Requires.NotNull(fields, "fields");
throw new NotImplementedException();
}
///
/// Analyzes an incoming request message payload to discover what kind of
/// message is embedded in it and returns the type, or null if no match is found.
///
/// The message that was sent as a request that resulted in the response.
/// The name/value pairs that make up the message payload.
///
/// A newly instantiated -derived object that this message can
/// deserialize to. Null if the request isn't recognized as a valid protocol message.
///
IDirectResponseProtocolMessage IMessageFactory.GetNewResponseMessage(IDirectedProtocolMessage request, IDictionary fields) {
Requires.NotNull(request, "request");
Requires.NotNull(fields, "fields");
throw new NotImplementedException();
}
#endregion
}
}