summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.OpenId/Configuration/AssociationTypeElement.cs
blob: c64913d9d31628eaa708ef808d54557249d0feb3 (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
//-----------------------------------------------------------------------
// <copyright file="AssociationTypeElement.cs" company="Outercurve Foundation">
//     Copyright (c) Outercurve Foundation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace DotNetOpenAuth.Configuration {
	using System;
	using System.Collections.Generic;
	using System.Configuration;
	using System.Linq;
	using System.Text;

	/// <summary>
	/// Describes an association type and its maximum lifetime as an element
	/// in a .config file.
	/// </summary>
	internal class AssociationTypeElement : ConfigurationElement {
		/// <summary>
		/// The name of the attribute that stores the association type.
		/// </summary>
		private const string AssociationTypeConfigName = "type";

		/// <summary>
		/// The name of the attribute that stores the association's maximum lifetime.
		/// </summary>
		private const string MaximumLifetimeConfigName = "lifetime";

		/// <summary>
		/// Initializes a new instance of the <see cref="AssociationTypeElement"/> class.
		/// </summary>
		internal AssociationTypeElement() {
		}

		/// <summary>
		/// Gets or sets the protocol name of the association.
		/// </summary>
		[ConfigurationProperty(AssociationTypeConfigName, IsRequired = true, IsKey = true)]
		////[StringValidator(MinLength = 1)]
		public string AssociationType {
			get { return (string)this[AssociationTypeConfigName]; }
			set { this[AssociationTypeConfigName] = value; }
		}

		/// <summary>
		/// Gets or sets the maximum time a shared association should live.
		/// </summary>
		/// <value>The default value is 14 days.</value>
		[ConfigurationProperty(MaximumLifetimeConfigName, IsRequired = true)]
		public TimeSpan MaximumLifetime {
			get { return (TimeSpan)this[MaximumLifetimeConfigName]; }
			set { this[MaximumLifetimeConfigName] = value; }
		}
	}
}