Hi,gus,
I'm developing a custom component designer,by this designer,user can configuration a data source,the UI just like the "DataSource configuration Wizard" in IDE.
but what I only need is the data table scheme the user selected,I do not want it add a DataSet(*.xsd) file to my project.
In fact,I can call a "Datasource Configuration Wizard" by DataSourceProviderService.InvokeAddNewDataSource() Method,but this will add a
excrescent *.xsd file to my project.
And I can alsocall Microsoft.Data.ConnectionUI.Dialog.DataConnectionDialog,but,in this case,the user can not select an existed connectionstring in app.config.
So I want implement this wizard bymyself,but I don't know how retrive the existed connectionstrings in project app.config.
I tried the ConfigurationManager.AppSettings["ConnectonString"],but it seem to retrive from Machine.config.
I use reflector to see the source code of DataGridView control,and I monitor the value of DataSourceProviderService by following code:
DataSourceProviderService dspSvc = (DataSourceProviderService)this.Component.Site.GetService(typeof(DataSourceProviderService));
Type tp=dspSvc.GetType();
and I found the exactly type of dspSve is and VSDDataSourceProviderService,its code like bellow:
internal class VSDDataSourceProviderService : DataSourceProviderService
{
// Fields
private List<GenericObjectDataSource> wsDataSourcesAdded;
// Methods
public VSDDataSourceProviderService();
public override object AddDataSourceInstance(IDesignerHost host, DataSourceDescriptor dsd);
private void DsStorage_DataSourceChanged(object sender, GenericObjectDataSourceStorage.ChangedEventArgs e);
public override DataSourceGroupCollection GetDataSources();
public override DataSourceGroup InvokeAddNewDataSource(IWin32Window parentWindow, FormStartPosition startPosition);
public override bool InvokeConfigureDataSource(IWin32Window parentWindow, FormStartPosition startPosition, DataSourceDescriptor dsd);
public override void NotifyDataSourceComponentAdded(object dataSourceComponent);
// Properties
public override bool SupportsAddNewDataSource { get; }
public override bool SupportsConfigureDataSource { get; }
}
The source code of its InvokeAddNewDataSourcemethod like bellow:
public override DataSourceGroup InvokeAddNewDataSource(IWin32Window parentWindow, FormStartPosition startPosition)
{
IServiceProvider serviceProvider = ProviderServiceHelper.GetServiceProvider();
Project currentProject = ProjectItemUtil.GetCurrentProject();
if (currentProject != null)
{
//bla bla bla
}
}
All of these classes,methods are internal or sealed,I can't invoke them.How can I implement the function? Is my direction wrong?
What's the exactly solution?