Skip to content

Instantly share code, notes, and snippets.

View mkorman's full-sized avatar

Mariano Korman mkorman

  • Location-independent
View GitHub Profile
global interface InstallHandler {
void onInstall(InstallContext context)
}
global class PostInstallScript implements InstallHandler {
global void onInstall (InstallContext context) {
InitializePackage();
}
}
global class PostInstallScript implements InstallHandler {
global void onInstall (InstallContext context) {
// Only initialize package on a fresh install!
if (context.previousVersion == null) {
InitializePackage();
}
}
}
global class PostInstallScript implements InstallHandler {
global void onInstall (InstallContext context)
{
// Only initialize package on a fresh install!
if (context.previousVersion == null)
{
InitializePackage();
}
// Migrate data, but only for versions older than 1.2
else if (context.previousVersion().CompareTo(new Version (1,2)) < 0)
global class PostInstallScript implements InstallHandler {
global void onInstall (InstallContext context)
{
// Initialize package (and new feature) on fresh installs
if (context.previousVersion() == null)
{
InitializePackage();
InitializeFeature13();
}
global class PostInstallScript implements InstallHandler {
global void onInstall (InstallContext context)
{
new Feature10Installer().onInstall(context);
new Feature12Installer().onInstall(context);
new Feature13Installer().onInstall(context);
}
}
public class Feature10Installer implements InstallHandler {
global void OnInstall (InstallContext context)
{
// Only initialize package on a fresh install!
if (context.previousVersion() == null)
{
InitializePackage();
}
}
}
public class Feature12Installer implements InstallHandler {
global void onInstall (InstallContext context)
{
// Migrate data, but only for versions older than 1.2
if (context.previousVersion != null && context.previousVersion().CompareTo(new Version (1,2)) < 0)
{
UpgradeForFeature12();
}
}
public class Feature13Installer implements InstallHandler {
global void onInstall (InstallContext context)
{
if (context.previousVersion() == null)
{
InitializePackage();
}
else if (context.previousVersion().CompareTo(new Version (1,3)) < 0)
{
public abstract class InstallHandlerBase implements InstallHandler
{
public abstract Version GetLastPackageVersionWithoutFeature ();
public void onInstall(InstallContext context)
{
if (isFreshInstall (context))
{
OnFreshInstall (context);
}