Exemplo n.º 1
0
    public static string GetSourceDisplayName(
        IServiceProvider serviceProvider,
        IVsDataSource dataSource)
    {
        string displayName = null;
        string resourceId  = null;
        Guid   provider    = dataSource.DefaultProvider;

        if (provider != Guid.Empty)
        {
            resourceId = dataSource.GetProperty(provider, "DisplayName") as string;
        }
        if (resourceId == null)
        {
            foreach (Guid providerId in dataSource.GetProviders())
            {
                resourceId = dataSource.GetProperty(
                    providerId, "DisplayName") as string;
                if (resourceId != null)
                {
                    provider = providerId;
                    break;
                }
            }
        }
        if (provider != Guid.Empty && resourceId != null)
        {
            IVsDataProviderManager providerManager = serviceProvider.GetService(
                typeof(IVsDataProviderManager)) as IVsDataProviderManager;
            IVsDataProvider dataProvider = providerManager.Providers[provider];
            displayName = dataProvider.GetString(resourceId);
        }
        return(displayName);
    }
Exemplo n.º 2
0
    public static string GetDisplayName(
        IVsDataProvider provider)
    {
        string displayName = String.Empty;
        string resourceId  = provider.GetProperty("DisplayName") as string;

        if (resourceId != null)
        {
            displayName = provider.GetString(resourceId);
        }
        return(displayName);
    }