Freigeben über


IVsDataProviderDynamicSupport.IsOperationSupported-Methode

Bestimmt, ob ein Einzelgeschäft in die aktuelle Umgebung unterstützt wird, 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 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

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: Boolean
true , wenn der Vorgang vom Anbieter in der aktuellen Umgebung unterstützt wird; andernfalls false.

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 dynamisch ändern, welche Operationen für den Benutzer, abhängig von der aktuellen Umgebung und einem bestimmten Kontext innerhalb dieser Umgebung verfügbar sind. Das bedeutet, dass sich der Anbieter der aktuellen Computerkonfiguration anpassen und dem, was Komponenten, die den DDEX-Anbieter unterstützen, installiert werden. Eine häufige Verwendung dieser Methode würde, Unterstützung für einen bestimmten Vorgang, der von der Verfügbarkeit einer bestimmten Komponente auf dem Computer ab, wie einem Skriptmodul zu aktivieren oder zu deaktivieren sein.

Beispiele

Der folgende Code zeigt, wie diese Methode implementiert, dass er einen Bereitstellungsbefehl auf einem Verbindungsknoten im Datenexplorer unterstützt nur wenn ein bestimmter Registrierungsschlüssel vorhanden ist und angibt, dass eine bestimmte Bereitstellungstechnologie installiert ist.

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