IVsDataProviderDynamicSupport.IsOperationSupported メソッド

特定の操作が現在の環境でサポートされている指定 DDEX のデータ ソースでかどうかを判断します。

名前空間:  Microsoft.VisualStudio.Data.Core
アセンブリ:  Microsoft.VisualStudio.Data.Core (Microsoft.VisualStudio.Data.Core.dll 内)

構文

'宣言
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

パラメーター

  • source
    型 : System.Guid
    DDEX のデータ ソースの識別子。
  • context
    型 : System.Object
    操作があるコンテキストを表すオブジェクト。

戻り値

型 : System.Boolean
操作が現在の環境のプロバイダーでサポートされている場合true ; それ以外 false。

例外

例外 条件
ArgumentNullException

command パラメーターが nullnull 参照 (Visual Basic では Nothing) です。

ArgumentException

context のパラメーターは、指定した操作の予想値ではありません。

解説

このメソッドは、動的にどの操作がその環境内の現在の環境や特定のコンテキストでユーザーが使用できるか変更を DDEX プロバイダーを有効にします。つまり、プロバイダーは現在のコンピューターの構成に適合させることができ、DDEX プロバイダーをサポートするコンポーネントをインストールする。このメソッドのは一般的に、コンピューター上の特定のコンポーネントの可用性に依存するスクリプト エンジンなどの特定の操作のサポートを有効または無効にすることです。

次のコードは、特定のレジストリ キーがある場合にのみ、特定の配置テクノロジがインストールされていることを示すデータのエクスプローラーの接続ノードの展開のコマンドをサポートする場合は、このメソッドを実装する方法を示します。

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 セキュリティ

  • 直前の呼び出し元に対する完全な信頼。このメンバーは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

関連項目

IVsDataProviderDynamicSupport インターフェイス

Microsoft.VisualStudio.Data.Core 名前空間