summaryrefslogtreecommitdiffstats
path: root/src/DotNetOAuth/Messaging/Reflection/MessageDescription.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2008-09-21 12:39:32 -0700
committerAndrew <andrewarnott@gmail.com>2008-09-21 12:39:32 -0700
commit76c4a164c8af4b5239834934bfa8915a60678ed5 (patch)
treebcf40394f040fced8b7b121d4a2d7f9367c78985 /src/DotNetOAuth/Messaging/Reflection/MessageDescription.cs
parent3b3a1836352fc2d50cb2698f9a2910aa1f9ba0d2 (diff)
downloadDotNetOpenAuth-76c4a164c8af4b5239834934bfa8915a60678ed5.zip
DotNetOpenAuth-76c4a164c8af4b5239834934bfa8915a60678ed5.tar.gz
DotNetOpenAuth-76c4a164c8af4b5239834934bfa8915a60678ed5.tar.bz2
StylCop and FxCop work.
Diffstat (limited to 'src/DotNetOAuth/Messaging/Reflection/MessageDescription.cs')
-rw-r--r--src/DotNetOAuth/Messaging/Reflection/MessageDescription.cs59
1 files changed, 48 insertions, 11 deletions
diff --git a/src/DotNetOAuth/Messaging/Reflection/MessageDescription.cs b/src/DotNetOAuth/Messaging/Reflection/MessageDescription.cs
index 9442f15..0f180c9 100644
--- a/src/DotNetOAuth/Messaging/Reflection/MessageDescription.cs
+++ b/src/DotNetOAuth/Messaging/Reflection/MessageDescription.cs
@@ -7,16 +7,36 @@
namespace DotNetOAuth.Messaging.Reflection {
using System;
using System.Collections.Generic;
+ using System.Diagnostics;
+ using System.Globalization;
using System.Linq;
using System.Reflection;
- using System.Globalization;
- using System.Diagnostics;
+ /// <summary>
+ /// A mapping between serialized key names and <see cref="MessagePart"/> instances describing
+ /// those key/values pairs.
+ /// </summary>
internal class MessageDescription {
- private static Dictionary<Type, MessageDescription> reflectedMessageTypes = new Dictionary<Type,MessageDescription>();
+ /// <summary>
+ /// A dictionary of reflected message types and the generated reflection information.
+ /// </summary>
+ private static Dictionary<Type, MessageDescription> reflectedMessageTypes = new Dictionary<Type, MessageDescription>();
+
+ /// <summary>
+ /// The type of message this instance was generated from.
+ /// </summary>
private Type messageType;
+
+ /// <summary>
+ /// A mapping between the serialized key names and their
+ /// describing <see cref="MessagePart"/> instances.
+ /// </summary>
private Dictionary<string, MessagePart> mapping;
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MessageDescription"/> class.
+ /// </summary>
+ /// <param name="messageType">The type of message to reflect over.</param>
private MessageDescription(Type messageType) {
Debug.Assert(messageType != null, "messageType == null");
@@ -32,6 +52,20 @@ namespace DotNetOAuth.Messaging.Reflection {
this.ReflectMessageType();
}
+ /// <summary>
+ /// Gets the mapping between the serialized key names and their describing
+ /// <see cref="MessagePart"/> instances.
+ /// </summary>
+ internal IDictionary<string, MessagePart> Mapping {
+ get { return this.mapping; }
+ }
+
+ /// <summary>
+ /// Gets a <see cref="MessageDescription"/> instance prepared for the
+ /// given message type.
+ /// </summary>
+ /// <param name="messageType">A type that implements <see cref="IProtocolMessage"/>.</param>
+ /// <returns>A <see cref="MessageDescription"/> instance.</returns>
internal static MessageDescription Get(Type messageType) {
if (messageType == null) {
throw new ArgumentNullException("messageType");
@@ -49,10 +83,10 @@ namespace DotNetOAuth.Messaging.Reflection {
return result;
}
- internal IDictionary<string, MessagePart> Mapping {
- get { return this.mapping; }
- }
-
+ /// <summary>
+ /// Reflects over some <see cref="IProtocolMessage"/>-implementing type
+ /// and prepares to serialize/deserialize instances of that type.
+ /// </summary>
internal void ReflectMessageType() {
this.mapping = new Dictionary<string, MessagePart>();
@@ -75,16 +109,19 @@ namespace DotNetOAuth.Messaging.Reflection {
/// Verifies that a given set of keys include all the required parameters
/// for this message type or throws an exception.
/// </summary>
+ /// <param name="keys">The names of all parameters included in a message.</param>
/// <exception cref="ProtocolException">Thrown when required parts of a message are not in <paramref name="keys"/></exception>
internal void EnsureRequiredMessagePartsArePresent(IEnumerable<string> keys) {
var missingKeys = (from part in Mapping.Values
where part.IsRequired && !keys.Contains(part.Name)
select part.Name).ToArray();
if (missingKeys.Length > 0) {
- throw new ProtocolException(string.Format(CultureInfo.CurrentCulture,
- MessagingStrings.RequiredParametersMissing,
- this.messageType.FullName,
- string.Join(", ", missingKeys)));
+ throw new ProtocolException(
+ string.Format(
+ CultureInfo.CurrentCulture,
+ MessagingStrings.RequiredParametersMissing,
+ this.messageType.FullName,
+ string.Join(", ", missingKeys)));
}
}
}