summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenId/Extensions/AttributeRequest.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenId/Extensions/AttributeRequest.cs')
-rw-r--r--src/DotNetOpenId/Extensions/AttributeRequest.cs45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/DotNetOpenId/Extensions/AttributeRequest.cs b/src/DotNetOpenId/Extensions/AttributeRequest.cs
new file mode 100644
index 0000000..4c8e947
--- /dev/null
+++ b/src/DotNetOpenId/Extensions/AttributeRequest.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Globalization;
+
+namespace DotNetOpenId.Extensions {
+ /// <summary>
+ /// An individual attribute to be requested of the OpenID Provider using
+ /// the Attribute Exchange extension.
+ /// </summary>
+ public class AttributeRequest {
+ /// <summary>
+ /// The URI uniquely identifying the attribute being requested.
+ /// </summary>
+ public string TypeUri;
+ /// <summary>
+ /// Whether the relying party considers this a required field.
+ /// Note that even if set to true, the Provider may not provide the value.
+ /// </summary>
+ public bool IsRequired;
+ int count = 1;
+ /// <summary>
+ /// The maximum number of values for this attribute the
+ /// Relying Party wishes to receive from the OpenID Provider.
+ /// A value of int.MaxValue is considered infinity.
+ /// </summary>
+ public int Count {
+ get { return count; }
+ set {
+ if (value <= 0) throw new ArgumentOutOfRangeException("value");
+ count = value;
+ }
+ }
+
+ public AttributeResponse Respond(params string[] values) {
+ if (values == null) throw new ArgumentNullException("values");
+ if (values.Length > Count) throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,
+ Strings.AttributeTooManyValues, Count, TypeUri, values.Length));
+ return new AttributeResponse {
+ TypeUri = this.TypeUri,
+ Values = values,
+ };
+ }
+ }
+}