IVsDataProviderDynamicSupport.GetUnsupportedReason 方法

获取描述该操作不支持的原因,的指定DDEX数据源的本地化字符串。

命名空间:  Microsoft.VisualStudio.Data.Core
程序集:  Microsoft.VisualStudio.Data.Core(在 Microsoft.VisualStudio.Data.Core.dll 中)

语法

声明
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

参数

  • source
    类型:System.Guid
    DDEX数据源标识符。
  • context
    类型:System.Object
    表示操作存在的上下文的对象。

返回值

类型:System.String
描述指定的原因的本地化字符串,不支持;如果操作实际上不支持;否则,nullnull 引用(在 Visual Basic 中为 Nothing)。

异常

异常 条件
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 命名空间