using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Data.ConnectionUI;
using Microsoft.VisualStudio.Data.AdoDotNet;
using DataConnectionProperties = Microsoft.VisualStudio.Data.DataConnectionProperties;
using DataConnectionUIControl = Microsoft.VisualStudio.Data.DataConnectionUIControl;

namespace Howest.Guidance.Extensions.Common.Data
{
	public class ExtensionsDataProvider : DataProvider
	{
		private Type _connectionProviderObjectFactoryType;

		public ExtensionsDataProvider(string name, string displayName, string shortDisplayName, string description, Type targetConnectionType, Type connectionProviderObjectFactoryType)
			: base(name, displayName, shortDisplayName, description, targetConnectionType)
		{
			_connectionProviderObjectFactoryType = connectionProviderObjectFactoryType;
		}
		public override IDataConnectionProperties CreateConnectionProperties(DataSource dataSource)
		{
			AdoDotNetProviderObjectFactory factory = (AdoDotNetProviderObjectFactory)Activator.CreateInstance(_connectionProviderObjectFactoryType);
			return (IDataConnectionProperties)factory.CreateObject(typeof(DataConnectionProperties));
			//return base.CreateConnectionProperties(dataSource);
		}

		public override IDataConnectionUIControl CreateConnectionUIControl(DataSource dataSource)
		{
			AdoDotNetProviderObjectFactory factory = (AdoDotNetProviderObjectFactory)Activator.CreateInstance(_connectionProviderObjectFactoryType);
			return (IDataConnectionUIControl)factory.CreateObject(typeof(DataConnectionUIControl));
			//return base.CreateConnectionUIControl(dataSource);
		}
	}
}
