summaryrefslogtreecommitdiffstats
path: root/src/DotNetOAuth/Messaging/MessagePartAttribute.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOAuth/Messaging/MessagePartAttribute.cs')
-rw-r--r--src/DotNetOAuth/Messaging/MessagePartAttribute.cs47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/DotNetOAuth/Messaging/MessagePartAttribute.cs b/src/DotNetOAuth/Messaging/MessagePartAttribute.cs
new file mode 100644
index 0000000..6620f7f
--- /dev/null
+++ b/src/DotNetOAuth/Messaging/MessagePartAttribute.cs
@@ -0,0 +1,47 @@
+//-----------------------------------------------------------------------
+// <copyright file="MessagePartAttribute.cs" company="Andrew Arnott">
+// Copyright (c) Andrew Arnott. All rights reserved.
+// </copyright>
+//-----------------------------------------------------------------------
+
+namespace DotNetOAuth.Messaging {
+ using System;
+ using System.Net.Security;
+ using System.Reflection;
+
+ [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, Inherited = true, AllowMultiple = false)]
+ internal sealed class MessagePartAttribute : Attribute {
+ private bool initialized;
+ private string name;
+
+ internal MessagePartAttribute() {
+ }
+
+ internal MessagePartAttribute(string name) {
+ this.Name = name;
+ }
+
+ public string Name {
+ get { return this.name; }
+ set { this.name = string.IsNullOrEmpty(value) ? null : value; }
+ }
+
+ public ProtectionLevel Signed { get; set; }
+
+ public bool Optional { 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;
+ }
+ }
+ }
+}