Using this attribute on a class will cause the CMS to call methods on it at startup. The following methods will be called, if they exist:
CopyC#
/* This handler will be called first, before C1 initialization, and allow you to register services exposed by <see cref="T:Composite.Core.ServiceLocator" />
public void ConfigureServices(<see cref="T:Microsoft.Extensions.DependencyInjection.IServiceCollection" /> serviceCollection) {}
/* This handler will be called before C1 initialization. The data layer cannot be used here. */
public void OnBeforeInitialize() {}
/* This handler will be called after initialization of C1 core. */
public void OnInitialized() {}

Namespace: Composite.Core.Application
Assembly: Composite (in Composite.dll) Version: 6.1.6325.31818

Syntax

C#
public sealed class ApplicationStartupAttribute : Attribute
Visual Basic
Public NotInheritable Class ApplicationStartupAttribute _
	Inherits Attribute
Visual C++
public ref class ApplicationStartupAttribute sealed : public Attribute

Examples

To register a service on ServiceLocator:
CopyC#
[ApplicationStartup]
public class MyServiceRegistration
{
    public void ConfigureServices(IServiceCollection serviceCollection)
    {
        // Register a singleton service that will be retrievable via Composite.Core.ServiceLocator
        serviceCollection.AddSingleton(typeof(ITestStuff), typeof(TestStuff));
    }
}
If OnBeforeInitialize() or OnInitialized() has any parameters, they will be provided via the ServiceLocator.
CopyC#
[ApplicationStartup]
public class MyAppStartupHandler
{
    public void OnBeforeInitialize()
    {
    }

    public void OnInitialized(Composite.Core.Logging.ILog log)
    {
        log.LogInformation("Dependency Injection supported here");
    }
}

Inheritance Hierarchy

System..::..Object
  System..::..Attribute
    Composite.Core.Application..::..ApplicationStartupAttribute

See Also