Class DataItemReader
- Namespace
- Dynamicweb.Deployment
- Assembly
- Dynamicweb.Deployment.dll
Represents a data item reader
public abstract class DataItemReader : IDisposable
- Inheritance
-
DataItemReader
- Implements
- Inherited Members
Examples
using System.Collections.Generic;
using System.Linq;
namespace Dynamicweb.Deployment.Examples
{
/// <summary>
/// This is an example of how to implement a custom data item reader.
/// </summary>
internal class CustomDataItemReader : DataItemReader
{
private CustomDataItemProvider customDataItemProvider;
public CustomDataItemReader(CustomDataItemProvider customDataItemProvider)
{
this.customDataItemProvider = customDataItemProvider;
}
/// <summary>
/// Reads the data items with the specified ids.
/// </summary>
/// <remarks>
/// It will be executed on both source and destination when doing a comparison.
/// </remarks>
/// <param name="ids">The ids.</param>
/// <returns>
/// A sequence of data items
/// </returns>
public override IEnumerable<DataItem> ReadItems(IEnumerable<string> ids)
{
var dataItems = new List<DataItem>();
// Check if we need to return all entries
var readAllEntries = ids.Any();
// Use additional parameters from the data item provider for looking up and filtering existing data (optional).
var myProperty = customDataItemProvider.MyProperty;
return dataItems;
}
}
}
Methods
CalculateChecksum(IDictionary<string, object>)
Calculates the checksum.
protected virtual string CalculateChecksum(IDictionary<string, object> properties)
Parameters
properties
IDictionary<string, object>- The data item properties that should be included in the calculation of checksum value.
Returns
Dispose()
public void Dispose()
Dispose(bool)
protected virtual void Dispose(bool disposing)
Parameters
disposing
bool
ReadItemInfos()
Reads the data item infos.
public IEnumerable<DataItemInfo> ReadItemInfos()
Returns
- IEnumerable<DataItemInfo>
- A sequence of data item infos
ReadItemInfos(IEnumerable<string>)
Reads the data item infos with the specified ids.
public virtual IEnumerable<DataItemInfo> ReadItemInfos(IEnumerable<string> ids)
Parameters
ids
IEnumerable<string>- The ids.
Returns
- IEnumerable<DataItemInfo>
- A sequence of data item infos
ReadItems()
Reads all the data items.
public IEnumerable<DataItem> ReadItems()
Returns
- IEnumerable<DataItem>
- A sequence of data items
ReadItems(IEnumerable<string>)
Reads the data items with the specified ids.
public abstract IEnumerable<DataItem> ReadItems(IEnumerable<string> ids)
Parameters
ids
IEnumerable<string>- The ids.
Returns
- IEnumerable<DataItem>
- A sequence of data items