using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;

namespace Howest.Guidance.Extensions.Common.Data
{
	public class DataProviderElement : ConfigurationElement
	{
		public DataProviderElement()
		{

		}

		private ConfigurationPropertyCollection _properties;

		protected override ConfigurationPropertyCollection Properties
		{
			get
			{
				if (_properties == null)
				{
					ConfigurationPropertyCollection props = new ConfigurationPropertyCollection();
					props.Add(new ConfigurationProperty("name", typeof(string), null, null, new StringValidator(1), ConfigurationPropertyOptions.IsKey | ConfigurationPropertyOptions.IsRequired));
					props.Add(new ConfigurationProperty("displayName", typeof(string), null, null, new StringValidator(1), ConfigurationPropertyOptions.IsRequired));
					props.Add(new ConfigurationProperty("shortDisplayName", typeof(string), null, null, new StringValidator(1), ConfigurationPropertyOptions.IsRequired));
					props.Add(new ConfigurationProperty("description", typeof(string), null, null, new StringValidator(1), ConfigurationPropertyOptions.IsRequired));
					props.Add(new ConfigurationProperty("dataSourceDisplayName", typeof(string), null, null, new StringValidator(1), ConfigurationPropertyOptions.IsRequired));
					props.Add(new ConfigurationProperty("connectionType", typeof(string), null, null, new StringValidator(1), ConfigurationPropertyOptions.IsRequired));
					props.Add(new ConfigurationProperty("providerObjectFactoryType", typeof(string), null, null, new StringValidator(1), ConfigurationPropertyOptions.IsRequired));
					props.Add(new ConfigurationProperty("clientFactoryType", typeof(string), null, null, new StringValidator(1), ConfigurationPropertyOptions.IsRequired));
					_properties = props;
				}
				return _properties;
			}
		}

		[ConfigurationProperty("name", Options = ConfigurationPropertyOptions.IsKey | ConfigurationPropertyOptions.IsRequired), StringValidator(MinLength = 1)]
		public string Name
		{
			get
			{
				return (string)base["name"];
			}
			set
			{
				if (string.IsNullOrEmpty(value))
				{
					value = string.Empty;
				}
				base["name"] = value;
			}
		}

		[ConfigurationProperty("displayName", Options = ConfigurationPropertyOptions.IsRequired), StringValidator(MinLength = 1)]
		public string DisplayName
		{
			get
			{
				return (string)base["displayName"];
			}
			set
			{
				if (string.IsNullOrEmpty(value))
				{
					value = string.Empty;
				}
				base["displayName"] = value;
			}
		}

		[ConfigurationProperty("shortDisplayName", Options = ConfigurationPropertyOptions.IsRequired), StringValidator(MinLength = 1)]
		public string ShortDisplayName
		{
			get
			{
				return (string)base["shortDisplayName"];
			}
			set
			{
				if (string.IsNullOrEmpty(value))
				{
					value = string.Empty;
				}
				base["shortDisplayName"] = value;
			}
		}

		[ConfigurationProperty("description", Options = ConfigurationPropertyOptions.IsRequired), StringValidator(MinLength = 1)]
		public string Description
		{
			get
			{
				return (string)base["description"];
			}
			set
			{
				if (string.IsNullOrEmpty(value))
				{
					value = string.Empty;
				}
				base["description"] = value;
			}
		}

		[ConfigurationProperty("dataSourceDisplayName", Options = ConfigurationPropertyOptions.IsRequired), StringValidator(MinLength = 1)]
		public string DataSourceDisplayName
		{
			get
			{
				return (string)base["dataSourceDisplayName"];
			}
			set
			{
				if (string.IsNullOrEmpty(value))
				{
					value = string.Empty;
				}
				base["dataSourceDisplayName"] = value;
			}
		}

		[ConfigurationProperty("connectionType", Options = ConfigurationPropertyOptions.IsRequired), StringValidator(MinLength = 1)]
		public string ConnectionType
		{
			get
			{
				return (string)base["connectionType"];
			}
			set
			{
				if (string.IsNullOrEmpty(value))
				{
					value = string.Empty;
				}
				base["connectionType"] = value;
			}
		}

		[ConfigurationProperty("providerObjectFactoryType", Options = ConfigurationPropertyOptions.IsRequired), StringValidator(MinLength = 1)]
		public string ProviderObjectFactoryType
		{
			get
			{
				return (string)base["providerObjectFactoryType"];
			}
			set
			{
				if (string.IsNullOrEmpty(value))
				{
					value = string.Empty;
				}
				base["providerObjectFactoryType"] = value;
			}
		}

		[ConfigurationProperty("clientFactoryType", Options = ConfigurationPropertyOptions.IsRequired), StringValidator(MinLength = 1)]
		public string ClientFactoryType
		{
			get
			{
				return (string)base["clientFactoryType"];
			}
			set
			{
				if (string.IsNullOrEmpty(value))
				{
					value = string.Empty;
				}
				base["clientFactoryType"] = value;
			}
		}
	}
}
