Пример #1
0
        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);
        }
Пример #2
0
    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");
    }