internal static IVsDataConnectionProperties GetConnectionProperties( IVsDataProviderManager dataProviderManager, IVsDataConnection dataConnection) { if (dataConnection == null) { throw new ArgumentNullException("dataConnection"); } IVsDataConnectionProperties properties = null; var provider = GetVsProvider(dataProviderManager, dataConnection); Debug.Assert(provider != null, "null provider value for dataConnection"); if (provider != null) { var dataSource = GetVsDataSource(dataProviderManager, dataConnection); properties = provider.TryCreateObject <IVsDataConnectionProperties>(dataSource); Debug.Assert(properties != null, "Could not get connection properties service"); if (properties != null) { var connectionString = DecryptConnectionString(dataConnection) ?? string.Empty; properties.Parse(connectionString); } } return(properties); }
protected override bool AreEquivalent(IVsDataConnectionProperties connectionProperties1, IVsDataConnectionProperties connectionProperties2) => connectionProperties1["Server"].ToString() == connectionProperties2["Server"].ToString() && connectionProperties1["Port"].ToString() == connectionProperties2["Port"].ToString() && connectionProperties1["Database"].ToString() == connectionProperties2["Database"].ToString() && connectionProperties1["User ID"].ToString() == connectionProperties2["User ID"].ToString() && connectionProperties1["Password"].ToString() == connectionProperties2["Password"].ToString() ;
public static IVsDataConnectionProperties CreateConnectionProperties( IVsDataProvider provider) { IVsDataConnectionProperties connProperties = null; try { connProperties = provider.CreateObject <IVsDataConnectionProperties>(); } catch (DataProviderException e) { MessageBox.Show(e.Message); } return(connProperties); }
public static void UseDataProvider( IServiceProvider serviceProvider, Guid providerGuid) { IVsDataProviderManager providerManager = serviceProvider.GetService(typeof(IVsDataProviderManager)) as IVsDataProviderManager; IVsDataProvider provider = providerManager.Providers[providerGuid]; Trace.WriteLine(provider.DisplayName); Trace.WriteLine(provider.Description); IVsDataConnectionProperties connectionProperties = provider.CreateObject <IVsDataConnectionProperties>(); connectionProperties.Parse("Test connection string"); }
protected override bool AreEquivalent(IVsDataConnectionProperties connectionProperties1, IVsDataConnectionProperties connectionProperties2) => connectionProperties1["Host"].ToString() == connectionProperties2["Host"].ToString() && connectionProperties1["Port"].ToString() == connectionProperties2["Port"].ToString() && connectionProperties1["Database"].ToString() == connectionProperties2["Database"].ToString() && connectionProperties1["Username"].ToString() == connectionProperties2["Username"].ToString() ;