summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth/OpenId/Extensions/AttributeExchange/AttributeValues.cs
blob: c1e2037414daeed507ea8440f8878016f476a524 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//-----------------------------------------------------------------------
// <copyright file="AttributeValues.cs" company="Andrew Arnott">
//     Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace DotNetOpenAuth.OpenId.Extensions.AttributeExchange {
	using System;
	using System.Collections.Generic;
	using System.Text;
	using System.Collections.ObjectModel;
	using DotNetOpenAuth.Messaging;

	/// <summary>
	/// An individual attribute's value(s) as supplied by an OpenID Provider
	/// in response to a prior request by an OpenID Relying Party as part of
	/// a fetch request, or by a relying party as part of a store request.
	/// </summary>
	[Serializable]
	public class AttributeValues {
		/// <summary>
		/// Initializes a new instance of the <see cref="AttributeValues"/> class.
		/// </summary>
		/// <remarks>
		/// This is internal because web sites should be using the
		/// <see cref="AttributeRequest.Respond"/> method to instantiate.
		/// </remarks>
		internal AttributeValues() {
			this.Values = new List<string>(1);
		}

		/// <summary>
		/// Initializes a new instance of the <see cref="AttributeValues"/> class.
		/// </summary>
		/// <param name="typeUri">The TypeURI of the attribute whose values are being provided.</param>
		internal AttributeValues(string typeUri) {
			ErrorUtilities.VerifyNonZeroLength(typeUri, "typeUri");

			this.TypeUri = typeUri;
			this.Values = new List<string>(1);
		}

		/// <summary>
		/// Instantiates an <see cref="AttributeValues"/> object.
		/// </summary>
		public AttributeValues(string typeUri, params string[] values) {
			ErrorUtilities.VerifyNonZeroLength(typeUri, "typeUri");

			this.TypeUri = typeUri;
			this.Values = (IList<string>)values ?? EmptyList<string>.Instance;
		}

		/// <summary>
		/// Gets the URI uniquely identifying the attribute whose value is being supplied.
		/// </summary>
		public string TypeUri { get; internal set; }

		/// <summary>
		/// Gets the values supplied by the Provider.
		/// </summary>
		public IList<string> Values { get; private set; }
	}
}