sitecore Unicorn Data Provider Architecture


There are two components to the Unicorn data provider: the database-specific implementation, and the Unicorn implementation.

The Unicorn implementation is an individual configuration of Unicorn dependencies that get automatic serialization. For example, if you were serializing two presets you'd need two instances of UnicornDataProvider - one for each IPredicate implementation.

The database specific implementation is a subclass of the original Sitecore data provider that provides a container for one or more UnicornDataProvider instances. Out of the box, a UnicornSqlServerDataProvider is provided. You could roll your own if you're on Oracle. This provider is effectively an unblockable event handler that allows Unicorn to trap item changes even if the evil EventDisabler class is being used.

If you want to wire multiple Unicorn data providers to your database, you create a class that derives from UnicornSqlServerDataProvider. In this class you can select to:

  • Create a constructor that injects your provider(s) using the base constructor:
public MyDataProvider(string connectionString) :
base(connectionString, new UnicornDataProvider(), new
UnicornDataProvider(), ...)
  • Create a constructor that injects your provider(s) using code (this is better if you have to construct dependencies, etc that don't fit well in a base call):
public MyDataProvider(string connectionString) : base(connectionString, null)
    AddUnicornDataProvider(new UnicornDataProvider());
    // ...