IVsDataProvider.IsOperationSupported Method (Guid, CommandID, Object)
Determines whether a specific operation is supported by the provider in the current environment, for the specified DDEX data source.
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
Parameters
source
Type: System.GuidA DDEX data source identifier.
command
Type: System.ComponentModel.Design.CommandIDA command that identifies the operation.
context
Type: System.ObjectAn object that represents the context in which the operation exists.
Return Value
Type: System.Boolean
true if the operation is supported by the provider in the current environment; otherwise, false.
Exceptions
Exception | Condition |
---|---|
ArgumentNullException | The command parameter is nulla null reference (Nothing in Visual Basic). |
[<ANY>] | The DDEX provider's IsOperationSupported implementation threw an exception. |
Remarks
This method enables DDEX clients to check whether specific operations are supported by a DDEX provider in the current environment. The environment can differ, depending on which edition of Visual Studio is running and which runtime components are installed on the computer. The former is typically controlled by the edition of Visual Studio (for example, restricting some commands on the Express editions), whereas the latter is typically controlled by a provider’s IVsDataProviderDynamicSupport implementation, if there is one.
Many operations occur within some larger context. The simplest example of this is the Open command for the connection, which occurs in the context of a particular connection. The context parameter of IsOperationSupported enables a recognizable object to be passed in and used as part of determining whether the operation is supported.
IsOperationSupported starts by determining whether the edition of Visual Studio supports the operation. If Visual Studio supports the operation and the provider has supplied an IVsDataProviderDynamicSupport implementation, the method queries the provider to determine whether the operation is supported.
Note that by default the Visual Studio edition supports all commands and excludes a select set of commands under certain conditions. This means that custom provider operations will be supported by the Visual Studio edition and are therefore controlled by the provider.
Examples
The following code demonstrates how to call this method to determine whether the provider supports the deletion of a particular data explorer node. If not, it calls the GetUnsupportedReason method to determine an appropriate message to describe why the operation is not supported.
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 Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.