diff options
Diffstat (limited to 'src/DotNetOpenId/Configuration/StoreElement.cs')
-rw-r--r-- | src/DotNetOpenId/Configuration/StoreElement.cs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/DotNetOpenId/Configuration/StoreElement.cs b/src/DotNetOpenId/Configuration/StoreElement.cs new file mode 100644 index 0000000..d2c94cb --- /dev/null +++ b/src/DotNetOpenId/Configuration/StoreElement.cs @@ -0,0 +1,24 @@ +using System;
+using System.Configuration;
+
+namespace DotNetOpenId.Configuration {
+ internal class StoreConfigurationElement<T> : ConfigurationElement {
+ public StoreConfigurationElement() { }
+
+ const string customStoreTypeConfigName = "type";
+ [ConfigurationProperty(customStoreTypeConfigName)]
+ //[SubclassTypeValidator(typeof(T))]
+ public string TypeName {
+ get { return (string)this[customStoreTypeConfigName]; }
+ set { this[customStoreTypeConfigName] = value; }
+ }
+
+ public Type CustomStoreType {
+ get { return string.IsNullOrEmpty(TypeName) ? null : Type.GetType(TypeName); }
+ }
+
+ public T CreateInstanceOfStore(T defaultValue) {
+ return CustomStoreType != null ? (T)Activator.CreateInstance(CustomStoreType) : defaultValue;
+ }
+ }
+}
|