IDataTypeConverter

Data type converters are applied to data types, the properties of document types that use those data types and the properties of content with those document types.

Methods

String GetConverterName()

Returns the name of the converter. This is shown in the Settings section of Converge for the switch for this converter.

String GetConverterDescription()

Returns the description of the converter. This is shown in the Settings section of Converge for the switch for this converter.

Version GetMinumumUmbracoVersion()

If you are unsure about how to implement this method, then simply return version 7.0.0 and the converter will always be applied.

Returns the first Umbraco version that this converter should be applied to. The converter switch will not be shown in the Settings section and the converter will not be applied to versions of Umbraco prior to the value returned by this method. The converter will be applied to all versions on or after this value.

Applies to the "local" site Umbraco version, that is the site that will be updated.

Boolean ConvertPropertyEditorAlias(String propertyEditorAlias)

Return true if a data type based on the property editor alias parameter should be converted by this converter, false otherwise. Note, this test is applied to the data type, document type properties and content properties to see if they should be updated by this class.

void ConvertDataType(DataTypeModel remoteDataType)

Performs the actual conversion of the data type. Change the remoteDataType parameter as required in this function.

void ConvertPropertyType(PropertyTypeModel remotePropertyType)

Convert any document type property that uses the data type. Change the remotePropertyType parameter as required in this function.

void ConvertProperty(PropertyModel remoteProperty)

Convert any content property that uses the data type. Change the remoteProperty parameter as required in this function.

Example

The following is the actual class included in Converge to deal with the renaming of "Checkbox" to "True/false" with the introduction of Umbraco 8.

public class CheckboxToTrueFalseDataTypeConverter : IDataTypeConverter
{
    public String GetConverterName()
    {
        return "Checkbox Rename";
    }
    
    public Boolean ConvertPropertyEditorAlias(String propertyEditorAlias)
    {
        return propertyEditorAlias == "Umbraco.TrueFalse";
    }
    
    public Version GetMinumumUmbracoVersion()
    {
        return new Version(8, 0, 0);
    }
    
    public string GetConverterDescription()
    {
        return "Rename Checkbox to True/false";
    }
    
    public void ConvertDataType(DataTypeModel remoteDataType)
    {
        if (remoteDataType.Name == "Checkbox")
        {
            remoteDataType.Name = "True/false";
        }
    }
    
    public void ConvertPropertyType(PropertyTypeModel remotePropertyType)
    {
        if (remotePropertyType.DataTypeName == "Checkbox")
        {
            remotePropertyType.DataTypeName = "True/false";
        }
    }
    
    public void ConvertProperty(PropertyModel remoteProperty)
    {
    }
}