Freigeben über


IVsDataProviderDynamicSupport.GetUnsupportedReason-Methode

Ruft eine lokalisierte Zeichenfolge ab, die den Grund beschreibt, den, ein Vorgang wird nicht unterstützt, für die angegebene DDEX-Datenquelle.

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

Syntax

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

Parameter

  • source
    Typ: Guid

    Ein DDEX-Datenquellenbezeichner.

  • command
    Typ: CommandID

    Ein Befehl, der den Vorgang identifiziert.

  • context
    Typ: Object

    Ein Objekt, das den Kontext darstellt, in dem der Vorgang vorhanden ist.

Rückgabewert

Typ: String
Eine lokalisierte Zeichenfolge, die beschreibt, warum der angegebene Vorgang wird nicht unterstützt, wenn der Vorgang tatsächlich nicht unterstützt wird; andernfalls nullein Nullverweis (Nothing in Visual Basic).

Ausnahmen

Ausnahme Bedingung
ArgumentNullException

Der command-Parameter ist nullein Nullverweis (Nothing in Visual Basic).

ArgumentException

Der context-Parameter ist nicht dem erwarteten Wert für den angegebenen Vorgang.

Hinweise

Mit dieser Methode können DDEX-Anbieter, um einen bestimmten Grund zurückzugeben, dass ein Vorgang nicht unterstützt wird. DDEX-Clienten können diesen Grund für den Benutzer angezeigt werden.

Beispiele

Der folgende Code zeigt, wie diese Methode implementiert, um eine nützliche Meldung zurückzugeben, wenn ein Bereitstellungsbefehl auf einem Verbindungsknoten im Datenexplorer nicht unterstützt wird.

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

.NET Framework-Sicherheit

Siehe auch

Referenz

IVsDataProviderDynamicSupport Schnittstelle

Microsoft.VisualStudio.Data.Core-Namespace