Create an initialization module
Describes how to create an initialization module to work with the initialization system in the Optimizely platform.
When you create your initialization module, add a reference to EPiServer.Framework.dll
. The following Initialization code example shows how a property is set up with a default implementation in Initialize, and then the process is undone in Uninitialize
:
[InitializableModule]
public class SampleInitialization: IInitializableModule {
public void Initialize(InitializationEngine context) {}
public void Uninitialize(InitializationEngine context) {}
}
- The initialization engine ensures that your code executes in a single-threaded manner.
You do not need to lock regions when you deal with a shared state. This guarantee is only made forInitialize
 andUnintialize
when you execute through the initialization system. You may have to deal with multi-threading issues if you have custom code that makes calls directly into your initialization module. - Remember that the initialization system tracks the initialization state of your module.
- Do an implementation of Uninitialize.
Anything you do withInitialize
 you should undo withÂUninitialize
in the reverse order of Initialize. This is especially important if you write integration tests that reset applications between test runs. - If you are using the Optimizely Content Management System (CMS) API, make sure you are adding a module dependency to CMS usingÂ
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
.
Updated 10 months ago