# Procedure

1. Implement the `ISiteSyncSnapIn` interface\
   In both projects, create a class and name it `CustomTypeSiteSyncSnapIn.cs`.\
   This class must implements the `ISiteSyncSnapIn` interface.
2. Register the custom items in the `Global.asax` class\
   Open the `Global.asax` and on `Application_Start`, attach an `EventHandler` method to the `SystemManager.ApplicationStart` event.\
   This handler registers your custom items.
3. Add the required members of the `CustomTypeSiteSyncSnapIn` class.
4. Subscribe to the `Created` event.\
   This tutorial uses `FileSystemWatcher` that provides the following file system events: `Changed`, `Deleted`, `Created`, and `Renamed`.

   To subscribe to the `Created` event, in the constructor of the `CustomTypeSiteSyncSnapIn` class, add the `App_Data\Sitefinity\Test` path that will be watched by the watcher and subscribe to the `Created` event.
5. Create a `SiteSync` log entry\
   Every time you create a new item inside folder `Test`, the event handler for the `Created` event is called. Inside this handler, you must create a site sync log entry for each target server.\
   To do this, you use the `dataStore` object and set the corresponding properties for the log entry.

   > success  **RESULT**: Every time you create a new folder or file inside the `Test` folder, a log entry for the created item is logged in the database.

   > info  **NOTE**: Immediately after you create a new folder or file, the event is raised. It gets the first (default) name of the item. Therefore, if you want to change the default name of the item, you must implement an event handler for the `Renamed` event of the `FileSystemWatcher` class.
6. Implement the methods of the `ISiteSyncSnapIn` interface.\
   You implement the following methods:
   * `GetPendingItems`\
     This method returns the items that are pending for synchronization for the current type.
   * `GetExportItemsCount`\
     This is a method that you implement for your custom snap-in. It gives you the number of the items that you have checked for export.\
     Inside this method, you call `GetExportItems`, which gets only the items that you have checked for syncing.
   * `Export`\
     This method is the method that exports the items for syncing.\
     Inside this method, you go through the log entries that are check for synchronization for the current type. For every log entry, you create a `WrapperObject` that you add to the export transaction. In this object, you can add properties and their values. You can also give an object with properties to the constructor of the `Wrapper` object. With the `CommonItemLoader` you can set the common properties for the log entry.\
     In the export transaction, you set the header for the current site sync snap-in and in the export transaction items you add the wrapper objects.

     > info  **NOTE**: You can choose how you want to export the items – all items in one transaction, or a separate transaction for each entry.
7. Save the items on the target server\
   You must also implement the logic for saving the items on the target server. For each exported transaction from the `Export` method, you must implement an `Import` method. It takes as parameter the current transaction with the exported items.
