IVsDataProviderDynamicSupport.IsOperationSupported, méthode

Détermine si une opération spécifique est prise en charge de l'environnement actif, pour la source de données spécifiée de DDEX.

Espace de noms :  Microsoft.VisualStudio.Data.Core
Assembly :  Microsoft.VisualStudio.Data.Core (dans Microsoft.VisualStudio.Data.Core.dll)

Syntaxe

'Déclaration
Function IsOperationSupported ( _
    source As Guid, _
    command As CommandID, _
    context As Object _
) As Boolean
bool IsOperationSupported(
    Guid source,
    CommandID command,
    Object context
)
bool IsOperationSupported(
    Guid source, 
    CommandID^ command, 
    Object^ context
)
abstract IsOperationSupported : 
        source:Guid * 
        command:CommandID * 
        context:Object -> bool
function IsOperationSupported(
    source : Guid, 
    command : CommandID, 
    context : Object
) : boolean

Paramètres

  • source
    Type : Guid

    Un identificateur de source de données de DDEX.

  • command
    Type : CommandID

    Une commande identificateur l'exécution.

  • context
    Type : Object

    Objet qui représente le contexte dans lequel l'exécution existe.

Valeur de retour

Type : Boolean
true si l'opération est prise en charge par le fournisseur dans l'environnement actuel ; sinon, false.

Exceptions

Exception Condition
ArgumentNullException

Le paramètre command est nullune référence null (Nothing en Visual Basic).

ArgumentException

Le paramètre d' context n'est pas une valeur attendue pour l'exécution spécifiée.

Notes

Cette méthode permet aux fournisseurs de DDEX de modifier dynamiquement les opérations qui sont disponibles pour l'utilisateur, en fonction de l'environnement actuel et un contexte particulier dans cet environnement. En d'autres termes, le fournisseur peut s'adapter à la configuration de l'ordinateur actuel et à quels composants qui prend en charge le fournisseur de DDEX sont installés. Une utilisation courante de cette méthode est d'activer ou de désactiver la prise en charge d'une opération particulière qui dépend de la disponibilité d'un composant particulier sur l'ordinateur, tel qu'un moteur de script.

Exemples

Le code suivant montre comment appliquer cette méthode de telle sorte qu'il prend en charge une commande deploy sur un nœud de connexion dans l'explorateur de données uniquement lorsqu'une clé de Registre particulière existe, indiquant qu'une technologie spécifique de déploiement est installée.

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

public class MyProviderDynamicSupport2 : IVsDataProviderDynamicSupport
{
    private static readonly CommandID DeployCommand =
        new CommandID(new Guid("6535F307-2083-4cbb-B2FA-11F2DCD69DAF"), 25);

    public bool IsProviderSupported
    {
        get
        {
            return true;
        }
    }

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

    public bool IsOperationSupported(
        Guid source, CommandID command, object context)
    {
        if (command == null)
        {
            throw new ArgumentNullException("command");
        }
        if (command.Equals(DeployCommand))
        {
            IVsDataExplorerConnection explorerConnection =
                context as IVsDataExplorerConnection;
            if (explorerConnection == null)
            {
                throw new ArgumentException();
            }
            RegistryKey key = Registry.LocalMachine.OpenSubKey(
                @"SOFTWARE\Company\DeployTechnology");
            if (key == null)
            {
                return false;
            }
            key.Close();
        }
        return true;
    }

    public string GetUnsupportedReason(
        Guid source, CommandID command, object context)
    {
        if (command == null)
        {
            throw new ArgumentNullException("command");
        }
        if (command.Equals(DeployCommand) &&
            !IsOperationSupported(source, command, context))
        {
            // Note: This string should be localized 
            return "In order to deploy a database you need to install our deployment technology.";
        }
        return null;
    }
}

Sécurité .NET Framework

Voir aussi

Référence

IVsDataProviderDynamicSupport Interface

Microsoft.VisualStudio.Data.Core, espace de noms