Class ScriptTypeProvider
- Namespace
- Dynamicweb.DataIntegration.Integration
- Assembly
- Dynamicweb.DataIntegration.dll
Extensibility point for transforming column values during a data integration job.
A script type provider is attached to a ColumnMapping and its GetValue(object?)
method is called for every row, receiving the source column value and returning the value to write to the
destination column. Built-in implementations include Append, Prepend, Constant, Substring, NewGuid,
CurrentTime and Invert (see the Dynamicweb.DataIntegration.Integration.ScriptTypes namespace).
public abstract class ScriptTypeProvider : ConfigurableAddIn
- Inheritance
-
ScriptTypeProvider
- Derived
-
ScriptTypeProvider<TReturnType>
- Inherited Members
Remarks
How to create a custom provider: Subclass ScriptTypeProvider<TReturnType> (preferred, as it gives a typed contract) or this class directly, decorate it with AddInLabelAttribute to control the display name in the mapping UI, and expose any configuration as public properties decorated with AddInParameterAttribute and an editor attribute — this class derives from ConfigurableAddIn, so parameters are rendered and persisted automatically. Deploy the assembly with the solution and the provider is discovered by the add-in system and becomes selectable on column mappings in the data integration job editor.
Things to be careful of:
- GetValue(object?) runs once per row. Keep it fast and allocation-light; avoid database or network calls per invocation. Cache expensive lookups.
- The input value may be
nullor DBNull — handle both. - When a provider is set on a mapping, its return value bypasses the standard source-to-destination type conversion, so the returned object must be compatible with the destination column type. Use Culture for any culture-sensitive parsing or formatting instead of the thread culture.
- Instances must be XML-serializable through the ConfigurableAddIn parameter system: keep configuration in add-in parameter properties and provide a public parameterless constructor.
- The context properties (Job, Mapping, SourceColumn,
DestinationColumn, Culture) are populated by the framework when the provider is
assigned to a mapping; they are
nulluntil then, so do not rely on them in the constructor.
using Dynamicweb.Extensibility.AddIns;
using Dynamicweb.Extensibility.Editors;
using Dynamicweb.DataIntegration.Integration;
[AddInLabel("Upper case")]
public class UpperCaseScriptType : ScriptTypeProvider<string>
{
[AddInParameter("TrimValue"), AddInLabel("Trim value"), AddInParameterGroup("Scripting"), AddInParameterEditor(typeof(YesNoParameterEditor), "")]
public bool TrimValue { get; set; }
public override IEnumerable<Type> AllowedTypes { get; set; } = new[] { typeof(string) };
public override string GetValueTyped(object? input)
{
var value = input?.ToString() ?? string.Empty;
if (TrimValue)
value = value.Trim();
return value.ToUpper(Culture ?? System.Globalization.CultureInfo.InvariantCulture);
}
}
Properties
AllowedTypes
Gets or sets the column types this provider can be applied to. When set, the mapping UI only offers this provider for columns whose type is in the collection; an empty collection (the default) means the provider is available for all column types.
public virtual IEnumerable<Type> AllowedTypes { get; set; }
Property Value
Culture
Gets the culture of the column mapping, falling back to the destination language culture of the job.
Use this for culture-sensitive parsing and formatting in GetValue(object?) instead of the
thread culture. Populated by the framework; null before the provider is assigned to a column mapping.
public CultureInfo? Culture { get; }
Property Value
DestinationColumn
Gets the destination column of the column mapping the provider is assigned to. Populated by the framework;
null before the provider is assigned to a column mapping.
public Column? DestinationColumn { get; }
Property Value
DisableSource
Gets a value indicating whether the provider produces its value independently of a source column.
When true (for example the Constant and NewGuid script types), the mapping does not require a source
column and readers/writers skip reading the source value for the mapping. The default is false.
public virtual bool DisableSource { get; }
Property Value
Job
Gets the job the provider is executing in. Populated by the framework when the provider is assigned to a
column mapping; null before that.
public Job? Job { get; }
Property Value
Mapping
Gets the table mapping that owns the column mapping the provider is assigned to. Populated by the framework;
null before the provider is assigned to a column mapping.
public Mapping? Mapping { get; }
Property Value
SourceColumn
Gets the source column of the column mapping the provider is assigned to. Populated by the framework;
null before assignment or when the mapping has no source column (see DisableSource).
public Column? SourceColumn { get; }
Property Value
Methods
GetValue(object?)
Transforms a source value into the value written to the destination column. Called once per row during job execution with the value of SourceColumn for that row.
public abstract object? GetValue(object? input)
Parameters
inputobjectThe value read from the source column for the current row. May be
nullor DBNull, and is alwaysnullwhen DisableSource istrueand no source column is mapped.
Returns
- object
The value to write to the destination column. Must be compatible with the destination column type, as no further type conversion is applied.