Table of Contents

Class DataItemWriter

Namespace
Dynamicweb.Deployment
Assembly
Dynamicweb.Core.dll

Represents a data item writer.

public abstract class DataItemWriter : IDisposable
Inheritance
DataItemWriter
Implements
Inherited Members

Examples

using System.Collections.Generic;

namespace Dynamicweb.Deployment.Examples
{
    /// <summary>
    /// This is an example of how to implement a custom data item writer.
    /// </summary>
    internal class CustomDataItemWriter : DataItemWriter
    {
        private CustomDataItemProvider customDataItemProvider;

        public CustomDataItemWriter(CustomDataItemProvider customDataItemProvider)
        {
            this.customDataItemProvider = customDataItemProvider;
        }

        /// <summary>
        /// Writes the data items.
        /// </summary>
        /// <remarks>
        /// It will be executed on the destination when transfering data from source to destination.
        /// </remarks>
        /// <param name="dataItems">The data items.</param>
        public override void WriteItems(IEnumerable<DataItem> dataItems)
        {
            foreach (var dataItem in dataItems)
            {
                // Use the data item id to lookup an existing entity (database record, file, etc.).
                var id = dataItem.Id;

                // Use additional parameters from the data item provider for looking up and filtering existing data (optional).
                var myProperty = customDataItemProvider.MyProperty;

                // Create or update the entity with the data item property values (database record, file, etc.).
                var properties = dataItem.Properties;    
            }
        }
    }
}

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Dispose(bool)

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

WriteItems(IEnumerable<DataItem>)

Writes the data items.

public abstract void WriteItems(IEnumerable<DataItem> dataItems)

Parameters

dataItems IEnumerable<DataItem>

The data items.

WriteItemsSecondPass(IEnumerable<DataItem>)

Writes the data items a second time. This is used for post processing data.

public virtual void WriteItemsSecondPass(IEnumerable<DataItem> dataItems)

Parameters

dataItems IEnumerable<DataItem>

The items.

To top