diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2008-09-20 12:09:56 -0700 |
---|---|---|
committer | Andrew <andrewarnott@gmail.com> | 2008-09-20 12:09:56 -0700 |
commit | ccd062ccfaa33aed1da1e39e62c07348392f4367 (patch) | |
tree | 870eea6e76aad96882d972f8a2cbeb0dfa380108 /src/DotNetOAuth/Messaging/Reflection | |
parent | 74784effd199c28cae39676082b988454a7b37fb (diff) | |
download | DotNetOpenAuth-ccd062ccfaa33aed1da1e39e62c07348392f4367.zip DotNetOpenAuth-ccd062ccfaa33aed1da1e39e62c07348392f4367.tar.gz DotNetOpenAuth-ccd062ccfaa33aed1da1e39e62c07348392f4367.tar.bz2 |
Worked on test coverage.
Diffstat (limited to 'src/DotNetOAuth/Messaging/Reflection')
3 files changed, 12 insertions, 23 deletions
diff --git a/src/DotNetOAuth/Messaging/Reflection/MessageDescription.cs b/src/DotNetOAuth/Messaging/Reflection/MessageDescription.cs index 6b898bb..9442f15 100644 --- a/src/DotNetOAuth/Messaging/Reflection/MessageDescription.cs +++ b/src/DotNetOAuth/Messaging/Reflection/MessageDescription.cs @@ -10,6 +10,7 @@ namespace DotNetOAuth.Messaging.Reflection { using System.Linq;
using System.Reflection;
using System.Globalization;
+ using System.Diagnostics;
internal class MessageDescription {
private static Dictionary<Type, MessageDescription> reflectedMessageTypes = new Dictionary<Type,MessageDescription>();
@@ -17,12 +18,14 @@ namespace DotNetOAuth.Messaging.Reflection { private Dictionary<string, MessagePart> mapping;
private MessageDescription(Type messageType) {
- if (messageType == null) {
- throw new ArgumentNullException("messageType");
- }
+ Debug.Assert(messageType != null, "messageType == null");
if (!typeof(IProtocolMessage).IsAssignableFrom(messageType)) {
- throw new ArgumentOutOfRangeException(); // TODO: better message
+ throw new ArgumentException(string.Format(
+ CultureInfo.CurrentCulture,
+ MessagingStrings.UnexpectedType,
+ typeof(IProtocolMessage),
+ messageType));
}
this.messageType = messageType;
@@ -46,10 +49,6 @@ namespace DotNetOAuth.Messaging.Reflection { return result;
}
- internal Type MessageType {
- get { return this.messageType; }
- }
-
internal IDictionary<string, MessagePart> Mapping {
get { return this.mapping; }
}
diff --git a/src/DotNetOAuth/Messaging/Reflection/MessagePart.cs b/src/DotNetOAuth/Messaging/Reflection/MessagePart.cs index 4d2ebe6..3f64e63 100644 --- a/src/DotNetOAuth/Messaging/Reflection/MessagePart.cs +++ b/src/DotNetOAuth/Messaging/Reflection/MessagePart.cs @@ -38,7 +38,11 @@ namespace DotNetOAuth.Messaging.Reflection { this.field = member as FieldInfo;
this.property = member as PropertyInfo;
if (this.field == null && this.property == null) {
- throw new ArgumentOutOfRangeException("member"); // TODO: add descriptive message
+ throw new ArgumentException(string.Format(
+ CultureInfo.CurrentCulture,
+ MessagingStrings.UnexpectedType,
+ typeof(FieldInfo).Name + ", " + typeof(PropertyInfo).Name,
+ member.GetType().Name), "member");
}
if (attribute == null) {
diff --git a/src/DotNetOAuth/Messaging/Reflection/MessagePartAttribute.cs b/src/DotNetOAuth/Messaging/Reflection/MessagePartAttribute.cs index e5c429e..92960a8 100644 --- a/src/DotNetOAuth/Messaging/Reflection/MessagePartAttribute.cs +++ b/src/DotNetOAuth/Messaging/Reflection/MessagePartAttribute.cs @@ -29,19 +29,5 @@ namespace DotNetOAuth.Messaging.Reflection { public ProtectionLevel Signed { get; set; }
public bool IsRequired { get; set; }
-
- internal void Initialize(MemberInfo member) {
- if (member == null) {
- throw new ArgumentNullException("member");
- }
-
- if (!this.initialized) {
- if (String.IsNullOrEmpty(this.Name)) {
- this.Name = member.Name;
- }
-
- this.initialized = true;
- }
- }
}
}
|