# OpcDataTypeMapper Members

> Reference: Provides an abstract implementation of the IOpcDataTypeMapper interface.

<dl class="api-definition">
<dt>Type</dt>
<dd><a href="./">OpcDataTypeMapper</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>
<dt>Also in</dt>
<dd>Opc.UaFx.Client</dd>
</dl>

## Constructors

### OpcDataTypeMapper

<span class="api-meta">protected</span>

Initializes a new instance of the [OpcDataTypeMapper](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypemapper/) class.

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

```csharp
protected OpcDataTypeMapper()
```

</div>

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

```vbnet
Protected Sub New()
```

</div>

## Properties

### SourceType

<span class="api-meta">abstract</span>

Gets the [Type](https://learn.microsoft.com/dotnet/api/system.type) from an [object](https://learn.microsoft.com/dotnet/api/system.object) can be mapped to the [TargetType](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypemapper/members#targettype) using this [OpcDataTypeMapper](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypemapper/).

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

```csharp
public abstract Type SourceType { get; }
```

</div>

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

```vbnet
Public MustOverride ReadOnly Property SourceType As Type
```

</div>

**Property value**

[Type](https://learn.microsoft.com/dotnet/api/system.type)

The [Type](https://learn.microsoft.com/dotnet/api/system.type) which can be mapped.

### TargetType

<span class="api-meta">abstract</span>

Gets the [Type](https://learn.microsoft.com/dotnet/api/system.type) to that an [object](https://learn.microsoft.com/dotnet/api/system.object) is mapped using this [OpcDataTypeMapper](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypemapper/).

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

```csharp
public abstract Type TargetType { get; }
```

</div>

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

```vbnet
Public MustOverride ReadOnly Property TargetType As Type
```

</div>

**Property value**

[Type](https://learn.microsoft.com/dotnet/api/system.type)

The resulting [Type](https://learn.microsoft.com/dotnet/api/system.type) after mapping an [object](https://learn.microsoft.com/dotnet/api/system.object) of the [SourceType](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypemapper/members#sourcetype).

## Methods

### Convert

Converts the `source`[object](https://learn.microsoft.com/dotnet/api/system.object) to a specific type.

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

```csharp
public object Convert(object source, IFormatProvider provider)
```

</div>

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

```vbnet
Public Function Convert(source As Object, provider As IFormatProvider) As Object
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `source` | [Object](https://learn.microsoft.com/dotnet/api/system.object) | The `source`[object](https://learn.microsoft.com/dotnet/api/system.object) to convert. |
| `provider` | [IFormatProvider](https://learn.microsoft.com/dotnet/api/system.iformatprovider) | The [IFormatProvider](https://learn.microsoft.com/dotnet/api/system.iformatprovider) to control any formatting which may be necessary for the convertion. |

**Returns**

[Object](https://learn.microsoft.com/dotnet/api/system.object)

The converted [object](https://learn.microsoft.com/dotnet/api/system.object) determined through the `source`[object](https://learn.microsoft.com/dotnet/api/system.object) and the `provider` specified.

**Implements**

[Convert](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcdatatypemapper/members#convert)

### ConvertBack

Converts the `target`[object](https://learn.microsoft.com/dotnet/api/system.object) to the type from which the value has been created.

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

```csharp
public object ConvertBack(object target, IFormatProvider provider)
```

</div>

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

```vbnet
Public Function ConvertBack(
    target As Object,
    provider As IFormatProvider) As Object
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `target` | [Object](https://learn.microsoft.com/dotnet/api/system.object) | The `target`[object](https://learn.microsoft.com/dotnet/api/system.object) to convert back. |
| `provider` | [IFormatProvider](https://learn.microsoft.com/dotnet/api/system.iformatprovider) | The [IFormatProvider](https://learn.microsoft.com/dotnet/api/system.iformatprovider) to control any formatting which may be necessary for the convertion. |

**Returns**

[Object](https://learn.microsoft.com/dotnet/api/system.object)

The source [object](https://learn.microsoft.com/dotnet/api/system.object) from which `target` has been created.

**Implements**

[ConvertBack](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcdatatypemapper/members#convertback)

### ConvertBackCore

<span class="api-meta">protected · abstract</span>

When implemented in a derived class; converts the `target`[object](https://learn.microsoft.com/dotnet/api/system.object) to the type from which the value has been created.

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

```csharp
protected abstract object ConvertBackCore(
    object target,
    IFormatProvider provider)
```

</div>

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

```vbnet
Protected MustOverride Function ConvertBackCore(
    target As Object,
    provider As IFormatProvider) As Object
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `target` | [Object](https://learn.microsoft.com/dotnet/api/system.object) | The `target`[object](https://learn.microsoft.com/dotnet/api/system.object) to convert back. |
| `provider` | [IFormatProvider](https://learn.microsoft.com/dotnet/api/system.iformatprovider) | The [IFormatProvider](https://learn.microsoft.com/dotnet/api/system.iformatprovider) to control any formatting which may be necessary for the convertion. |

**Returns**

[Object](https://learn.microsoft.com/dotnet/api/system.object)

The source [object](https://learn.microsoft.com/dotnet/api/system.object) from which `target` has been created.

**Remarks**

This method is only used in case there `target` is not a null reference (Nothing in Visual Basic).

### ConvertCore

<span class="api-meta">protected · abstract</span>

When implemented in a derived class; converts the `source`[object](https://learn.microsoft.com/dotnet/api/system.object) to a specific type.

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

```csharp
protected abstract object ConvertCore(object source, IFormatProvider provider)
```

</div>

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

```vbnet
Protected MustOverride Function ConvertCore(
    source As Object,
    provider As IFormatProvider) As Object
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `source` | [Object](https://learn.microsoft.com/dotnet/api/system.object) | The `source`[object](https://learn.microsoft.com/dotnet/api/system.object) to convert. |
| `provider` | [IFormatProvider](https://learn.microsoft.com/dotnet/api/system.iformatprovider) | The [IFormatProvider](https://learn.microsoft.com/dotnet/api/system.iformatprovider) to control any formatting which may be necessary for the convertion. |

**Returns**

[Object](https://learn.microsoft.com/dotnet/api/system.object)

The converted [object](https://learn.microsoft.com/dotnet/api/system.object) determined through the `source`[object](https://learn.microsoft.com/dotnet/api/system.object) and the `provider` specified.

**Remarks**

This method is only used in case there `source` is not a null reference (Nothing in Visual Basic).

### Convertible

<span class="api-meta">static</span>

Provides an [OpcDataTypeMapper](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypemapper/) which utilizes the [IConvertible](https://learn.microsoft.com/dotnet/api/system.iconvertible) interface implemented by the `TSource` and `TTarget` types.

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

```csharp
public static OpcDataTypeMapper Convertible<TSource, TTarget>()
    where TSource : IConvertible
    where TTarget : IConvertible
```

</div>

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

```vbnet
Public Shared Function Convertible(Of TSource As IConvertible, TTarget As IConvertible)() As OpcDataTypeMapper
```

</div>

**Type parameters**

| Name | Description |
|---|---|
| `TSource` | The [Type](https://learn.microsoft.com/dotnet/api/system.type) implementing the [IConvertible](https://learn.microsoft.com/dotnet/api/system.iconvertible) interface and which is to be mapped to the `TTarget` type. |
| `TTarget` | The resulting [Type](https://learn.microsoft.com/dotnet/api/system.type) (implementing the [IConvertible](https://learn.microsoft.com/dotnet/api/system.iconvertible) interface) after mapping an [object](https://learn.microsoft.com/dotnet/api/system.object) of the `TSource` type. |

**Returns**

[OpcDataTypeMapper](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypemapper/)

An instance of the [OpcDataTypeMapper](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypemapper/) class utilizing the [IConvertible](https://learn.microsoft.com/dotnet/api/system.iconvertible) implementations of the `TSource` and `TTarget` to convert between the types.

### Delegate

<span class="api-meta">static</span>

Provides an [OpcDataTypeMapper](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypemapper/) which uses the `convert` and `convertBack` delegates.

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

```csharp
public static OpcDataTypeMapper Delegate<TSource, TTarget>(
    Func<TSource, IFormatProvider, TTarget> convert,
    Func<TTarget, IFormatProvider, TSource> convertBack)
```

</div>

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

```vbnet
Public Shared Function [Delegate](Of TSource, TTarget)(
    convert As Func(Of TSource, IFormatProvider, TTarget),
    convertBack As Func(Of TTarget, IFormatProvider, TSource)) As OpcDataTypeMapper
```

</div>

**Type parameters**

| Name | Description |
|---|---|
| `TSource` | The [Type](https://learn.microsoft.com/dotnet/api/system.type) which is to be mapped to the `TTarget` type. |
| `TTarget` | The resulting [Type](https://learn.microsoft.com/dotnet/api/system.type) after mapping an [object](https://learn.microsoft.com/dotnet/api/system.object) of the `TSource` type. |

**Parameters**

| Name | Type | Description |
|---|---|---|
| `convert` | [Func](https://learn.microsoft.com/dotnet/api/system.func-3)&lt;TSource, [IFormatProvider](https://learn.microsoft.com/dotnet/api/system.iformatprovider), TTarget&gt; | The delegate to use to map the `TSource`[object](https://learn.microsoft.com/dotnet/api/system.object) to the `TTarget` type. |
| `convertBack` | [Func](https://learn.microsoft.com/dotnet/api/system.func-3)&lt;TTarget, [IFormatProvider](https://learn.microsoft.com/dotnet/api/system.iformatprovider), TSource&gt; | The delegate to use to map the `TTarget`[object](https://learn.microsoft.com/dotnet/api/system.object) back to the `TSource` type. |

**Returns**

[OpcDataTypeMapper](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdatatypemapper/)

**Exceptions**

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