Condividi tramite


Metodo IVsDataProviderDynamicSupport.GetUnsupportedReason

Ottiene una stringa localizzata che descrive la causa di un'operazione non è supportata, per l'origine dati specificata di DDEX.

Spazio dei nomi:  Microsoft.VisualStudio.Data.Core
Assembly:  Microsoft.VisualStudio.Data.Core (in Microsoft.VisualStudio.Data.Core.dll)

Sintassi

'Dichiarazione
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

Parametri

  • source
    Tipo: Guid

    Un identificatore di origine dati di DDEX.

  • command
    Tipo: CommandID

    Un comando che identifica l'operazione.

  • context
    Tipo: Object

    Un oggetto che rappresenta il contesto in cui l'operazione esiste.

Valore restituito

Tipo: String
Stringa localizzata che descrive perché l'operazione specificata non è supportata, se l'operazione in effetti non è supportata; in caso contrario, nullriferimento null (Nothing in Visual Basic).

Eccezioni

Eccezione Condizione
ArgumentNullException

Il parametro command è nullriferimento null (Nothing in Visual Basic).

ArgumentException

Il parametro context non sia un valore previsto per l'operazione specificata.

Note

Questo metodo consente ai provider di DDEX per restituire un motivo specifico per cui un'operazione non è supportata. I client di DDEX possono visualizzare questo motivo all'utente.

Esempi

Il codice seguente viene illustrato come implementare questo metodo per restituire un messaggio utile quando un comando di distribuzione su un nodo della connessione in esplora di dati non supportato.

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;
    }
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

IVsDataProviderDynamicSupport Interfaccia

Spazio dei nomi Microsoft.VisualStudio.Data.Core