Partager via


IVsDataProviderDynamicSupport.GetUnsupportedReason, méthode

Obtient une chaîne localisée qui décrit la raison qu'une opération n'est pas prise en charge, 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 GetUnsupportedReason ( _
    source As Guid, _
    command As CommandID, _
    context As Object _
) As String
string GetUnsupportedReason(
    Guid source,
    CommandID command,
    Object context
)
String^ GetUnsupportedReason(
    Guid source, 
    CommandID^ command, 
    Object^ context
)
abstract GetUnsupportedReason : 
        source:Guid * 
        command:CommandID * 
        context:Object -> string 
function GetUnsupportedReason(
    source : Guid, 
    command : CommandID, 
    context : Object
) : String

Paramètres

  • source
    Type : System.Guid
    Un identificateur de source de données de DDEX.
  • context
    Type : System.Object
    Objet qui représente le contexte dans lequel l'exécution existe.

Valeur de retour

Type : System.String
Chaîne localisée qui décrit la raison pour laquelle l'exécution spécifiée n'est pas prise en charge, si l'opération en fait n'est pas prise en charge ; sinon, nullune référence null (Nothing en Visual Basic).

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 retourner une raison pour laquelle une opération n'est pas prise en charge.Les clients de DDEX peuvent afficher cette raison à l'utilisateur.

Exemples

Le code suivant montre comment appliquer cette méthode pour retourner un message utile lorsqu'une commande deploy sur un nœud de connexion dans l'explorateur de données n'est pas prise en charge.

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