IVsDataProvider.IsOperationSupported 方法 (Guid, CommandID, Object)

为指定的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)。

[<ANY>]

DDEX提供程序的 IsOperationSupported 实现引发了异常。

备注

此方法使DDEX客户端检查特定操作是否由一个DDEX提供程序在当前环境中支持。环境可能不同,Visual Studio编辑器运行,而运行时组件安装在计算机上。前者由Visual Studio版本中通常为控件(例如,限制在速成版中的某些命令),而后者通常由提供程序的 IVsDataProviderDynamicSupport 实现控件的,因此,如果有一个。

许多操作在某些更大的上下文内。此的简单示例是连接中打开命令,发生在特定连接中。IsOperationSupported 的 context 参数使可识别的对象通过和用作确定一部分操作是否支持。

IsOperationSupported 通过确定Visual Studio的版本是否支持开始操作。如果Visual Studio支持操作,并且提供程序提供了一个 IVsDataProviderDynamicSupport 实现,该方法查询提供程序确定操作是否支持。

请注意在特定条件下默认情况下Visual Studio编辑器支持所有命令并选择排除组命令。这意味着因此自定义提供程序操作将由Visual Studio编辑器支持和是提供程序的控件。

示例

下面的代码演示如何调用此方法确定提供程序是否支持特定数据资源管理器节点中删除。否则,它调用 GetUnsupportedReason 方法确定适当的消息描述的原因不受支持。

C#

using System;
using System.Windows.Forms;
using System.ComponentModel.Design;
using Microsoft.VisualStudio.Data.Core;
using Microsoft.VisualStudio.Data.Services;

public class DDEX_IVsDataProviderExample8
{
    public static bool AllowDelete(IVsDataProvider provider,
        IVsDataExplorerNode node)
    {
        if (!provider.IsOperationSupported(StandardCommands.Delete, node))
        {
            MessageBox.Show(provider.GetUnsupportedReason(
                StandardCommands.Delete, node));
            return false;
        }
        return true;
    }
}

.NET Framework 安全性

请参见

参考

IVsDataProvider 接口

IsOperationSupported 重载

Microsoft.VisualStudio.Data.Core 命名空间