Partager via


IVsDataProviderDynamicSupport Interface

Provides the ability to alter the support of a DDEX provider, its supported sources, and specific operations, based on the current environment.

Namespace:  Microsoft.VisualStudio.Data.Core
Assembly:  Microsoft.VisualStudio.Data.Core (in Microsoft.VisualStudio.Data.Core.dll)

Syntax

'Declaration
Public Interface IVsDataProviderDynamicSupport
public interface IVsDataProviderDynamicSupport
public interface class IVsDataProviderDynamicSupport
type IVsDataProviderDynamicSupport =  interface end
public interface IVsDataProviderDynamicSupport

The IVsDataProviderDynamicSupport type exposes the following members.

Properties

  Name Description
Public property IsProviderSupported Gets a value indicating whether the provider is supported in the current environment.

Top

Methods

  Name Description
Public method GetUnsupportedReason Gets a localized string describing the reason an operation is not supported, for the specified DDEX data source.
Public method IsOperationSupported Determines whether a specific operation is supported in the current environment, for the specified DDEX data source.
Public method IsSourceSupported Gets a value indicating whether a particular DDEX data source is supported by this DDEX provider in the current environment.

Top

Remarks

A DDEX provider registers its existence for a particular installation of Visual Studio by adding specific registry keys to the Visual Studio local registry hive. Under normal circumstances, this registration is an indication that the provider exists and should be available for use in the instance of Visual Studio. However, in some circumstances it is necessary to allow the DDEX provider to determine dynamically if it should be supported in the environment, or whether it supports a particular data source or certain operations. This can be the case if particular components used or targeted by the DDEX provider are not installed, for example, a runtime ADO.NET provider that the DDEX provider represents at design time.

This support entity enables the DDEX provider to choose when it is available in the environment, which data sources it is able to support, and which specific operations are allowed. The first two choices affect whether the data provider and/or data source are enumerated and returned by the IVsDataProviderManager and IVsDataSourceManager services, respectively. The third choice affects the behavior of the IsOperationSupported and GetUnsupportedReason methods.

Examples

The following code demonstrates how a DDEX provider can implement this support entity with specific logic that dynamically alters its availability at design time, depending on the existence of a specific registry key.

using System;
using System.ComponentModel.Design;
using Microsoft.Win32;
using Microsoft.VisualStudio.Data.Core;

internal class MyProviderDynamicSupport : IVsDataProviderDynamicSupport
{
    public bool IsProviderSupported
    {
        get
        {
            RegistryKey key = Registry.LocalMachine.OpenSubKey(
                @"SOFTWARE\Company\AdoDotNetProvider");
            if (key == null)
            {
                return false;
            }
            key.Close();
            return true;
        }
    }

    public bool IsSourceSupported(Guid source)
    {
        return true;
    }

    public bool IsOperationSupported(
        Guid source, CommandID command, object context)
    {
        return true;
    }

    public string GetUnsupportedReason(
        Guid source, CommandID command, object context)
    {
        return null;
    }
}

See Also

Reference

Microsoft.VisualStudio.Data.Core Namespace