# OpcMethodDelegateCommand Members

> Reference: Provides an implementation of the IOpcMethodCommand interface which delegates method evaluations and method calls to a set of callback routines.

<dl class="api-definition">
<dt>Type</dt>
<dd><a href="./">OpcMethodDelegateCommand</a></dd>
<dt>Namespace</dt>
<dd><a href="../namespaces/opc.uafx">Opc.UaFx</a></dd>
<dt>Assembly</dt>
<dd>Opc.UaFx.Advanced.dll</dd>
<dt>Package</dt>
<dd>Opc.UaFx.Advanced v2.59.0</dd>
</dl>

## Constructors

### OpcMethodDelegateCommand

<span class="api-meta">3 overloads</span>

| Overload | Description |
|---|---|
| [OpcMethodDelegateCommand(OpcMethodExecuteCallback)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethoddelegatecommand/members#opcmethoddelegatecommand-opc-uafx-opcmethodexecutecallback) | Initializes a new instance of the [OpcMethodDelegateCommand](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethoddelegatecommand/) class using the `executeCallback` specified. |
| [OpcMethodDelegateCommand(OpcMethodExecuteCallback, OpcMethodCanExecuteCallback)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethoddelegatecommand/members#opcmethoddelegatecommand-opc-uafx-opcmethodexecutecallback-opc-uafx-opcmethodcanexecutecallback) | Initializes a new instance of the [OpcMethodDelegateCommand](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethoddelegatecommand/) class using the `executeCallback` and `canExecuteCallback` specified. |
| [OpcMethodDelegateCommand(OpcMethodExecuteCallback, OpcMethodCanExecuteCallback, OpcMethodCanExecuteCallback)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethoddelegatecommand/members#opcmethoddelegatecommand-opc-uafx-opcmethodexecutecallback-opc-uafx-opcmethodcanexecutecallback-opc-uafx-opcmethodcanexecutecallback) | Initializes a new instance of the [OpcMethodDelegateCommand](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethoddelegatecommand/) class using the `executeCallback`, `canExecuteCallback` and `canUserExecuteCallback` specified. |

#### OpcMethodDelegateCommand(OpcMethodExecuteCallback)

Initializes a new instance of the [OpcMethodDelegateCommand](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethoddelegatecommand/) class using the `executeCallback` specified.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcMethodDelegateCommand(OpcMethodExecuteCallback executeCallback)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Sub New(executeCallback As OpcMethodExecuteCallback)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `executeCallback` | [OpcMethodExecuteCallback](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethodexecutecallback/) | The [OpcMethodExecuteCallback](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethodexecutecallback/) which is invoked whenever the method of this command is called. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `executeCallback` is a null reference (Nothing in Visual Basic). |

#### OpcMethodDelegateCommand(OpcMethodExecuteCallback, OpcMethodCanExecuteCallback)

Initializes a new instance of the [OpcMethodDelegateCommand](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethoddelegatecommand/) class using the `executeCallback` and `canExecuteCallback` specified.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcMethodDelegateCommand(
    OpcMethodExecuteCallback executeCallback,
    OpcMethodCanExecuteCallback canExecuteCallback)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Sub New(
    executeCallback As OpcMethodExecuteCallback,
    canExecuteCallback As OpcMethodCanExecuteCallback)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `executeCallback` | [OpcMethodExecuteCallback](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethodexecutecallback/) | The [OpcMethodExecuteCallback](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethodexecutecallback/) which is invoked whenever the `canExecuteCallback` evaluates to the value true as soon as the method of this command is called. |
| `canExecuteCallback` | [OpcMethodCanExecuteCallback](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethodcanexecutecallback/) | The [OpcMethodCanExecuteCallback](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethodcanexecutecallback/) which is used to evaluate whether the method of this command can be called in general and by the current user. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `executeCallback` or `canExecuteCallback` is a null reference (Nothing in Visual Basic). |

#### OpcMethodDelegateCommand(OpcMethodExecuteCallback, OpcMethodCanExecuteCallback, OpcMethodCanExecuteCallback)

Initializes a new instance of the [OpcMethodDelegateCommand](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethoddelegatecommand/) class using the `executeCallback`, `canExecuteCallback` and `canUserExecuteCallback` specified.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcMethodDelegateCommand(
    OpcMethodExecuteCallback executeCallback,
    OpcMethodCanExecuteCallback canExecuteCallback,
    OpcMethodCanExecuteCallback canUserExecuteCallback)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Sub New(
    executeCallback As OpcMethodExecuteCallback,
    canExecuteCallback As OpcMethodCanExecuteCallback,
    canUserExecuteCallback As OpcMethodCanExecuteCallback)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `executeCallback` | [OpcMethodExecuteCallback](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethodexecutecallback/) | The [OpcMethodExecuteCallback](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethodexecutecallback/) which is invoked whenever the `canExecuteCallback` and `canUserExecuteCallback` evaluate to the value true as soons as the method of this command is called. |
| `canExecuteCallback` | [OpcMethodCanExecuteCallback](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethodcanexecutecallback/) | The [OpcMethodCanExecuteCallback](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethodcanexecutecallback/) which is used to evaluate whether the method of this command can be called in general. |
| `canUserExecuteCallback` | [OpcMethodCanExecuteCallback](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethodcanexecutecallback/) | The [OpcMethodCanExecuteCallback](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethodcanexecutecallback/) which is used to evaluate whether the method of this command can be called by the current user. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `executeCallback`, `canExecuteCallback` or `canUserExecuteCallback` is a null reference (Nothing in Visual Basic). |

## Methods

### CanExecute

Determines the value of the [Executable](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcattribute/#executable) attribute of the method ([CanExecute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethodnode/members#canexecute)) and therefore decides whether the [Execute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethoddelegatecommand/members#execute) method can be called in general to execute the method implementation.

<div class="api-signature" data-lang="csharp">

```csharp
public bool CanExecute(OpcContext context)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Function CanExecute(context As OpcContext) As Boolean
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `context` | [OpcContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccontext/) | The [OpcReadAttributeValueContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreadattributevaluecontext/) in case there the [Executable](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcattribute/#executable) attribute is read or the [OpcMethodContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethodcontext/) in case there the method call is to be processed. |

**Returns**

[Boolean](https://learn.microsoft.com/dotnet/api/system.boolean)

The value true if the method can be called; otherwise the value false.

**Implements**

[CanExecute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcmethodcommand/members#canexecute)

### CanUserExecute

Determines the value of the [UserExecutable](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcattribute/#userexecutable) attribute of the method ([CanUserExecute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethodnode/members#canuserexecute)) and therefore decides wether the [Execute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethoddelegatecommand/members#execute) method can be called by the current user to execute the method implementation.

<div class="api-signature" data-lang="csharp">

```csharp
public bool CanUserExecute(OpcContext context)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Function CanUserExecute(context As OpcContext) As Boolean
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `context` | [OpcContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccontext/) | The [OpcReadAttributeValueContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreadattributevaluecontext/) in case there the [UserExecutable](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcattribute/#userexecutable) attribute is read or the [OpcMethodContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethodcontext/) in case there the method call is to be processed. |

**Returns**

[Boolean](https://learn.microsoft.com/dotnet/api/system.boolean)

The value true if the method can be called; otherwise the value false.

**Implements**

[CanUserExecute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcmethodcommand/members#canuserexecute)

### Execute

Performs the tasks necessary to implement the logic associated with a specific method using the `context` and `inputArguments` specified.

<div class="api-signature" data-lang="csharp">

```csharp
public void Execute(
    OpcMethodContext context,
    IList<object> inputArguments,
    IList<object> outputArguments)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Sub Execute(
    context As OpcMethodContext,
    inputArguments As IList(Of Object),
    outputArguments As IList(Of Object))
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `context` | [OpcMethodContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethodcontext/) | The [OpcMethodContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethodcontext/) which provides the contextual information required to execute the method. |
| `inputArguments` | [IList](https://learn.microsoft.com/dotnet/api/system.collections.generic.ilist-1)&lt;[Object](https://learn.microsoft.com/dotnet/api/system.object)&gt; | The generic list of [object](https://learn.microsoft.com/dotnet/api/system.object) values to use / respect during the execution of the method. |
| `outputArguments` | [IList](https://learn.microsoft.com/dotnet/api/system.collections.generic.ilist-1)&lt;[Object](https://learn.microsoft.com/dotnet/api/system.object)&gt; | The generic list of [object](https://learn.microsoft.com/dotnet/api/system.object) values to use for out, ref (in Visual Basic ByRef) and returned values. |

**Implements**

[Execute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcmethodcommand/members#execute)

**Remarks**

Any OPC UA related result information is to be set using the [Result](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethodcontext/members#result) property of the `context`.

This method is (to be) only called after the call to [CanExecute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethoddelegatecommand/members#canexecute) and [CanUserExecute](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcmethoddelegatecommand/members#canuserexecute) evaluates to the value true.
