ApplicationServer

Overview

The ApplicationServer class provides base application startup infrastructure including Windows Service management and single instance checks.

The ApplicationServer class is designed to provide a common codebase and simplify development of Remoting SDK and Data Abstract-based server applications. This class provides the following features: * 3 application run modes - GUI mode (WinForms or WPF), command-line interface or Windows Service * Windows Service management (installation/deinstallation) * Optional Single Instance check * Extensible startup arguments parser. The ApplicationServer class provides overridable method to handle command-line arguments not handled by default arguments parser. Also it is possible to use own implementation of the Interface IArgumentParser interface. * Single exception intercept point (useful for logging etc)

By default ApplicationServer-based applications recognize following command-line arguments (not case-sensitive): {| class="dashed-table" ! style="width: 40% " |

Parameters
! style="width: 60% " |
Description
|- | -I, /I, --INSTALL | Install service |- | -U, /U, --UNINSTALL | Install service |- | -Q, /Q, --QUIET | Suppress messages on service installation and uninstallation |- | -C, /C, --COMMANDLINE | Run in CLI mode |- | -D, /D, --DEBUG | Request extended debug info (ie full stacktraces) |- | -H, /H, -?, /? | Show command-line arguments help message |}

You don't have to write any code to handle these actions.

Here is the example how the ApplicationServer class is used in the Wizard-generated Data Abstract server project:

class SimpleProjectServer : ApplicationServer
{
    private Engine fConsoleEngine;

    protected override String Identifier
    {
        get
        {
            return "2a42e444-5b2c-4f5c-b73a-dd1cab801c0a";
        }
    }

    protected override String ServiceName
    {
        get
        {
            return "SimpleProject Service";
        }
    }

    protected override String ApplicationName
    {
        get
        {
            return "SimpleProject";
        }
    }

    protected override void RunAsConsoleApplication()
    {
        this.fConsoleEngine = new Engine();
        this.fConsoleEngine.Start();
    }

    protected override void ShutdownAsConsoleApplication()
    {
        this.fConsoleEngine.Stop();
        this.fConsoleEngine.Dispose();
    }

    protected override void RunAsWindowsService()
    {
        ServiceBase.Run(new MainService());
    }

    protected override void RunAsWindowsApplication()
    {
        Application.EnableVisualStyles();
        Application.Run(new MainForm());
    }
}

[STAThread]
public static void Main(String[] args)
{
    new SimpleProjectServer().Run(args);
}

Note: The ApplicationServer class (along with its inheritors) can be suitable for common scenarious. If application-specific startup parameters should be handled (f.e. --in-memory switch that activates pure in-memory mode for the Olympia Server) they can be handled via Extended Parameters (see the ProcessExtendedParameters method descriptions).

The ApplicationServer class is widely used used in Remoting SDK and Data Abstract for .NET. For instance Relativity Server, Olympia Server and RO ZeroConf Hub use this class to perform startup actions. Also all Data Abstract for .NET templates use this class as application base.

Location

 

constructor  protected

Creates a new instance of the ApplicationServer class.

This constructor can be called only from an inherited class.

 

constructor

 

ApplicationServer()

 

Sub New

constructor (String, array of Type)

 

constructor(applicationName: String; params serviceTypes: array of Type)

 

ApplicationServer(String applicationName, params Type[] serviceTypes)

 

Sub New (applicationName As String, ParamArray serviceTypes As array of Type)

Parameters:

  • applicationName:
  • serviceTypes:

constructor (String, String, array of Type)

 

constructor(applicationName: String; rodlNamespace: String; params serviceTypes: array of Type)

 

ApplicationServer(String applicationName, String rodlNamespace, params Type[] serviceTypes)

 

Sub New (applicationName As String, rodlNamespace As String, ParamArray serviceTypes As array of Type)

Parameters:

  • applicationName:
  • rodlNamespace:
  • serviceTypes:

constructor (String, String, String, String, array of Type)

 

constructor(applicationName: String; rodlNamespace: String; serviceName: String; serviceDescription: String; params serviceTypes: array of Type)

 

ApplicationServer(String applicationName, String rodlNamespace, String serviceName, String serviceDescription, params Type[] serviceTypes)

 

Sub New (applicationName As String, rodlNamespace As String, serviceName As String, serviceDescription As String, ParamArray serviceTypes As array of Type)

Parameters:

  • applicationName:
  • rodlNamespace:
  • serviceName:
  • serviceDescription:
  • serviceTypes:

add_ApplicationServerException

 

method add_ApplicationServerException(value: EventHandler<ApplicationServerExceptionEventArgs>)

 

void add_ApplicationServerException(EventHandler<ApplicationServerExceptionEventArgs> value)

 

Sub add_ApplicationServerException(value As EventHandler<ApplicationServerExceptionEventArgs>)

Parameters:

  • value:

add_CertificateGenerating

 

method add_CertificateGenerating(value: EventHandler<CertificateGeneratingEventArgs>)

 

void add_CertificateGenerating(EventHandler<CertificateGeneratingEventArgs> value)

 

Sub add_CertificateGenerating(value As EventHandler<CertificateGeneratingEventArgs>)

Parameters:

  • value:

add_Starting

 

method add_Starting(value: EventHandler)

 

void add_Starting(EventHandler value)

 

Sub add_Starting(value As EventHandler)

Parameters:

  • value:

add_Stopped

 

method add_Stopped(value: EventHandler)

 

void add_Stopped(EventHandler value)

 

Sub add_Stopped(value As EventHandler)

Parameters:

  • value:

ApplicationInfo  protected

Gets brief additional info (like copyrights etc) about the application.

This property is used by the help command output as well as in the console mode.

For example for the Relativity server this property returns Please visit http://wiki.remobjects.com/wiki/Relativity to get more information.

The default value of this property is an empty string.

 

property ApplicationInfo: String read;

 

String ApplicationInfo { get; }

 

Property ReadOnly ApplicationInfo As String

ApplicationName  protected

Gets full application name, for example RemObjects Data Abstract Relativity Server.

This is abstract property so it should be overriden.

 

property ApplicationName: String read;

 

String ApplicationName { get; }

 

Property ReadOnly ApplicationName As String

ApplicationServerException

 

event ApplicationServerException: EventHandler<ApplicationServerExceptionEventArgs>;

 

delegate EventHandler<ApplicationServerExceptionEventArgs> ApplicationServerException()

 

Event ApplicationServerException As EventHandler<ApplicationServerExceptionEventArgs>

AutoCreateSelfSignedCertificate

 

property AutoCreateSelfSignedCertificate: Boolean read write;

 

Boolean AutoCreateSelfSignedCertificate { get; set; }

 

Property AutoCreateSelfSignedCertificate As Boolean

CertificateGenerating

 

event CertificateGenerating: EventHandler<CertificateGeneratingEventArgs>;

 

delegate EventHandler<CertificateGeneratingEventArgs> CertificateGenerating()

 

Event CertificateGenerating As EventHandler<CertificateGeneratingEventArgs>

ConsoleServerFooter  protected

 

property ConsoleServerFooter: String read;

 

String ConsoleServerFooter { get; }

 

Property ReadOnly ConsoleServerFooter As String

CreateNetworkServer  protected

 

method CreateNetworkServer(configuration: INetworkServerConfiguration): INetworkServer

 

INetworkServer CreateNetworkServer(INetworkServerConfiguration configuration)

 

Function CreateNetworkServer(configuration As INetworkServerConfiguration) As INetworkServer

Parameters:

  • configuration:

CreateServerMainForm  protected

 

method CreateServerMainForm: Form

 

Form CreateServerMainForm()

 

Function CreateServerMainForm As Form

CreateServerWinService  protected

 

method CreateServerWinService: ServiceBase

 

ServiceBase CreateServerWinService()

 

Function CreateServerWinService As ServiceBase

ExtendedParameters  protected

Gets or sets extended (ie unrecognized) parameters returned by the IArgumentParser instance.

Usually these are parameters that cannot be processed by the IArgumentParser instance being used.

In most cases it is enough to override the ProcessExtendedParameters to handle advanced command-line options.

 

property ExtendedParameters: array of String read;

 

String[] ExtendedParameters { get; }

 

Property ReadOnly ExtendedParameters As array of String

ExtendedParametersDescription  protected

 

property ExtendedParametersDescription: String read;

 

String ExtendedParametersDescription { get; }

 

Property ReadOnly ExtendedParametersDescription As String

GetArgumentParser  protected

Returns a default implementation of the IArgumentParser.

If you need more profound logic of handling command-line arguments then you need to create your own implementation of the IArgumentParser interface. In that case you should override current method to make it return the instance of your custom parser.

 

method GetArgumentParser: IArgumentParser

 

IArgumentParser GetArgumentParser()

 

Function GetArgumentParser As IArgumentParser

GetSelfSignedCertificate  protected

 

method GetSelfSignedCertificate: X509Certificate2

 

X509Certificate2 GetSelfSignedCertificate()

 

Function GetSelfSignedCertificate As X509Certificate2

GetStartupOptionsHelpText  protected

Returns help string message.

By default this message contains description of common parameters and content of properties ApplicationInfo, HelpTextFooter, ExtendedParametersHelpText.

This method can be overriden to return custom help text.

 

method GetStartupOptionsHelpText: String

 

String GetStartupOptionsHelpText()

 

Function GetStartupOptionsHelpText As String

HelpTextFooter  protected

Gets the footer of help message. For example for the Relativity server this property returns Please visit http://wiki.remobjects.com/wiki/Relativity to get more information.

The default value of this property is an empty string.

 

property HelpTextFooter: String read;

 

String HelpTextFooter { get; }

 

Property ReadOnly HelpTextFooter As String

Identifier  protected

Gets applications unique identifier. This identifier is used to perform single-instance check during application startup.

This is abstract property so it should be overriden.

 

property Identifier: String read;

 

String Identifier { get; }

 

Property ReadOnly Identifier As String

Instance

The ApplicationServer class is a singleton. This property is used to access the current ApplicationServer class instance.

 

class property Instance: ApplicationServer read;

 

class ApplicationServer Instance { get; }

 

Shared Property ReadOnly Instance As ApplicationServer

IsAnotherInstanceDetected  protected

Gets or sets a flag indicating whether another rinning application instance has been detected.

 

property IsAnotherInstanceDetected: Boolean read;

 

Boolean IsAnotherInstanceDetected { get; }

 

Property ReadOnly IsAnotherInstanceDetected As Boolean

IsCheckForOtherInstancesRequired  protected

Gets a flag indicating whether single-instance check should be performed on application startup.

The default value of this property is true.

 

property IsCheckForOtherInstancesRequired: Boolean read;

 

Boolean IsCheckForOtherInstancesRequired { get; }

 

Property ReadOnly IsCheckForOtherInstancesRequired As Boolean

IsDebugEnabled  protected

Gets or sets flag indicating whether the Debug mode is active.

In the Debug mode the application will output extended information about unhandled exception (including stacktraces).

 

property IsDebugEnabled: Boolean read write;

 

Boolean IsDebugEnabled { get; set; }

 

Property IsDebugEnabled As Boolean

IsQuietModeEnabled  protected

Gets or sets flag indicating whether quiet run mode was requested.

Quiet mode suppresses all output from service installation installation/deinstallation calls and is very useful if it is needed to register an application as Windows Service during application setup.

 

property IsQuietModeEnabled: Boolean read write;

 

Boolean IsQuietModeEnabled { get; set; }

 

Property IsQuietModeEnabled As Boolean

IsWindowsPlatform  protected

 

class property IsWindowsPlatform: Boolean read;

 

class Boolean IsWindowsPlatform { get; }

 

Shared Property ReadOnly IsWindowsPlatform As Boolean

LoadApplicationServerConfiguration  protected

 

method LoadApplicationServerConfiguration

 

void LoadApplicationServerConfiguration()

 

Sub LoadApplicationServerConfiguration

NetworkServer

Gets the network server instance.

 

property NetworkServer: INetworkServer read;

 

INetworkServer NetworkServer { get; }

 

Property ReadOnly NetworkServer As INetworkServer

OnApplicationServerException  protected

 

method OnApplicationServerException(e: ApplicationServerExceptionEventArgs)

 

void OnApplicationServerException(ApplicationServerExceptionEventArgs e)

 

Sub OnApplicationServerException(e As ApplicationServerExceptionEventArgs)

Parameters:

  • e:

OnCertificateGenerating  protected

 

method OnCertificateGenerating(e: CertificateGeneratingEventArgs)

 

void OnCertificateGenerating(CertificateGeneratingEventArgs e)

 

Sub OnCertificateGenerating(e As CertificateGeneratingEventArgs)

Parameters:

  • e:

OnStarting  protected

 

method OnStarting

 

void OnStarting()

 

Sub OnStarting

OnStopped  protected

 

method OnStopped

 

void OnStopped()

 

Sub OnStopped

ProcessExtendedParameters  protected

If the IArgumentParser encounters command-line parameters it cannot process then this method is called.

By default this method forces application sartup code to show correct command-line options help and to exit.

Override this method to handle custom command-line parameters.

``` protected override void ProcessExtendedParameters() { if (this.ExtendedParameters[0] == "--sample") { // Application-specific actions needed to handle the --sample startup parameter } } </source >

 

method ProcessExtendedParameters

 

void ProcessExtendedParameters()

 

Sub ProcessExtendedParameters

remove_ApplicationServerException

 

method remove_ApplicationServerException(value: EventHandler<ApplicationServerExceptionEventArgs>)

 

void remove_ApplicationServerException(EventHandler<ApplicationServerExceptionEventArgs> value)

 

Sub remove_ApplicationServerException(value As EventHandler<ApplicationServerExceptionEventArgs>)

Parameters:

  • value:

remove_CertificateGenerating

 

method remove_CertificateGenerating(value: EventHandler<CertificateGeneratingEventArgs>)

 

void remove_CertificateGenerating(EventHandler<CertificateGeneratingEventArgs> value)

 

Sub remove_CertificateGenerating(value As EventHandler<CertificateGeneratingEventArgs>)

Parameters:

  • value:

remove_Starting

 

method remove_Starting(value: EventHandler)

 

void remove_Starting(EventHandler value)

 

Sub remove_Starting(value As EventHandler)

Parameters:

  • value:

remove_Stopped

 

method remove_Stopped(value: EventHandler)

 

void remove_Stopped(EventHandler value)

 

Sub remove_Stopped(value As EventHandler)

Parameters:

  • value:

RodlNamespace  protected

 

property RodlNamespace: String read write;

 

String RodlNamespace { get; set; }

 

Property RodlNamespace As String

Run

The main application startup entry point.

This method accepts command-line arguments, processes them and starts the application in appropriate mode.

 

method Run(arguments: array of String)

 

void Run(String[] arguments)

 

Sub Run(arguments As array of String)

Parameters:

  • arguments: Startup parameters.

RunAction

Gets current application run mode. See the ApplicationRunAction enumeration description for more details.

 

property RunAction: ApplicationRunAction read;

 

ApplicationRunAction RunAction { get; }

 

Property ReadOnly RunAction As ApplicationRunAction

RunAsConsoleApplication  protected

This method is called when command-line application run mode is requested.

This method should perform application startup procedures, f.e. initialize network and database connections etc.

 

method RunAsConsoleApplication

 

void RunAsConsoleApplication()

 

Sub RunAsConsoleApplication

RunAsWindowsApplication  protected

This method is called when GUI-enabled application run mode is requested.

This method should perform application startup procedures, f.e. initialize network and database connections etc and show the main application form, either WinForms, GTK or WPF.

 

method RunAsWindowsApplication

 

void RunAsWindowsApplication()

 

Sub RunAsWindowsApplication

RunAsWindowsService  protected

This method is called when application should be started as Windows Service.

This method should perform application startup procedures, f.e. initialize network and database connections etc.

 

method RunAsWindowsService

 

void RunAsWindowsService()

 

Sub RunAsWindowsService

RunAsWindowsServiceInstaller  protected

 

method RunAsWindowsServiceInstaller

 

void RunAsWindowsServiceInstaller()

 

Sub RunAsWindowsServiceInstaller

RunAsWindowsServiceUninstaller  protected

 

method RunAsWindowsServiceUninstaller

 

void RunAsWindowsServiceUninstaller()

 

Sub RunAsWindowsServiceUninstaller

ServiceName  protected

Gets the sthort application name that will be used as Windows Service name.

This is abstract property so it should be overriden.

 

property ServiceName: String read;

 

String ServiceName { get; }

 

Property ReadOnly ServiceName As String

ShutdownAsConsoleApplication  protected

This method is called when an application running in console mode is shut down.

Override this method to perform application shutdown procedures, f.e. closie network connections, release resources etc.

 

method ShutdownAsConsoleApplication

 

void ShutdownAsConsoleApplication()

 

Sub ShutdownAsConsoleApplication

Starting

 

event Starting: EventHandler;

 

delegate EventHandler Starting()

 

Event Starting As EventHandler

Stopped

 

event Stopped: EventHandler;

 

delegate EventHandler Stopped()

 

Event Stopped As EventHandler

 

ApplicationInfo  protected

Gets brief additional info (like copyrights etc) about the application.

This property is used by the help command output as well as in the console mode.

For example for the Relativity server this property returns Please visit http://wiki.remobjects.com/wiki/Relativity to get more information.

The default value of this property is an empty string.

 

property ApplicationInfo: String read;

 

String ApplicationInfo { get; }

 

Property ReadOnly ApplicationInfo As String

ApplicationName  protected

Gets full application name, for example RemObjects Data Abstract Relativity Server.

This is abstract property so it should be overriden.

 

property ApplicationName: String read;

 

String ApplicationName { get; }

 

Property ReadOnly ApplicationName As String

AutoCreateSelfSignedCertificate

 

property AutoCreateSelfSignedCertificate: Boolean read write;

 

Boolean AutoCreateSelfSignedCertificate { get; set; }

 

Property AutoCreateSelfSignedCertificate As Boolean

ConsoleServerFooter  protected

 

property ConsoleServerFooter: String read;

 

String ConsoleServerFooter { get; }

 

Property ReadOnly ConsoleServerFooter As String

ExtendedParameters  protected

Gets or sets extended (ie unrecognized) parameters returned by the IArgumentParser instance.

Usually these are parameters that cannot be processed by the IArgumentParser instance being used.

In most cases it is enough to override the ProcessExtendedParameters to handle advanced command-line options.

 

property ExtendedParameters: array of String read;

 

String[] ExtendedParameters { get; }

 

Property ReadOnly ExtendedParameters As array of String

ExtendedParametersDescription  protected

 

property ExtendedParametersDescription: String read;

 

String ExtendedParametersDescription { get; }

 

Property ReadOnly ExtendedParametersDescription As String

HelpTextFooter  protected

Gets the footer of help message. For example for the Relativity server this property returns Please visit http://wiki.remobjects.com/wiki/Relativity to get more information.

The default value of this property is an empty string.

 

property HelpTextFooter: String read;

 

String HelpTextFooter { get; }

 

Property ReadOnly HelpTextFooter As String

Identifier  protected

Gets applications unique identifier. This identifier is used to perform single-instance check during application startup.

This is abstract property so it should be overriden.

 

property Identifier: String read;

 

String Identifier { get; }

 

Property ReadOnly Identifier As String

IsAnotherInstanceDetected  protected

Gets or sets a flag indicating whether another rinning application instance has been detected.

 

property IsAnotherInstanceDetected: Boolean read;

 

Boolean IsAnotherInstanceDetected { get; }

 

Property ReadOnly IsAnotherInstanceDetected As Boolean

IsCheckForOtherInstancesRequired  protected

Gets a flag indicating whether single-instance check should be performed on application startup.

The default value of this property is true.

 

property IsCheckForOtherInstancesRequired: Boolean read;

 

Boolean IsCheckForOtherInstancesRequired { get; }

 

Property ReadOnly IsCheckForOtherInstancesRequired As Boolean

IsDebugEnabled  protected

Gets or sets flag indicating whether the Debug mode is active.

In the Debug mode the application will output extended information about unhandled exception (including stacktraces).

 

property IsDebugEnabled: Boolean read write;

 

Boolean IsDebugEnabled { get; set; }

 

Property IsDebugEnabled As Boolean

IsQuietModeEnabled  protected

Gets or sets flag indicating whether quiet run mode was requested.

Quiet mode suppresses all output from service installation installation/deinstallation calls and is very useful if it is needed to register an application as Windows Service during application setup.

 

property IsQuietModeEnabled: Boolean read write;

 

Boolean IsQuietModeEnabled { get; set; }

 

Property IsQuietModeEnabled As Boolean

NetworkServer

Gets the network server instance.

 

property NetworkServer: INetworkServer read;

 

INetworkServer NetworkServer { get; }

 

Property ReadOnly NetworkServer As INetworkServer

RodlNamespace  protected

 

property RodlNamespace: String read write;

 

String RodlNamespace { get; set; }

 

Property RodlNamespace As String

RunAction

Gets current application run mode. See the ApplicationRunAction enumeration description for more details.

 

property RunAction: ApplicationRunAction read;

 

ApplicationRunAction RunAction { get; }

 

Property ReadOnly RunAction As ApplicationRunAction

ServiceName  protected

Gets the sthort application name that will be used as Windows Service name.

This is abstract property so it should be overriden.

 

property ServiceName: String read;

 

String ServiceName { get; }

 

Property ReadOnly ServiceName As String

Instance

The ApplicationServer class is a singleton. This property is used to access the current ApplicationServer class instance.

 

class property Instance: ApplicationServer read;

 

class ApplicationServer Instance { get; }

 

Shared Property ReadOnly Instance As ApplicationServer

IsWindowsPlatform  protected

 

class property IsWindowsPlatform: Boolean read;

 

class Boolean IsWindowsPlatform { get; }

 

Shared Property ReadOnly IsWindowsPlatform As Boolean

 

constructor  protected

Creates a new instance of the ApplicationServer class.

This constructor can be called only from an inherited class.

 

constructor

 

ApplicationServer()

 

Sub New

constructor (String, array of Type)

 

constructor(applicationName: String; params serviceTypes: array of Type)

 

ApplicationServer(String applicationName, params Type[] serviceTypes)

 

Sub New (applicationName As String, ParamArray serviceTypes As array of Type)

Parameters:

  • applicationName:
  • serviceTypes:

constructor (String, String, array of Type)

 

constructor(applicationName: String; rodlNamespace: String; params serviceTypes: array of Type)

 

ApplicationServer(String applicationName, String rodlNamespace, params Type[] serviceTypes)

 

Sub New (applicationName As String, rodlNamespace As String, ParamArray serviceTypes As array of Type)

Parameters:

  • applicationName:
  • rodlNamespace:
  • serviceTypes:

constructor (String, String, String, String, array of Type)

 

constructor(applicationName: String; rodlNamespace: String; serviceName: String; serviceDescription: String; params serviceTypes: array of Type)

 

ApplicationServer(String applicationName, String rodlNamespace, String serviceName, String serviceDescription, params Type[] serviceTypes)

 

Sub New (applicationName As String, rodlNamespace As String, serviceName As String, serviceDescription As String, ParamArray serviceTypes As array of Type)

Parameters:

  • applicationName:
  • rodlNamespace:
  • serviceName:
  • serviceDescription:
  • serviceTypes:

add_ApplicationServerException

 

method add_ApplicationServerException(value: EventHandler<ApplicationServerExceptionEventArgs>)

 

void add_ApplicationServerException(EventHandler<ApplicationServerExceptionEventArgs> value)

 

Sub add_ApplicationServerException(value As EventHandler<ApplicationServerExceptionEventArgs>)

Parameters:

  • value:

add_CertificateGenerating

 

method add_CertificateGenerating(value: EventHandler<CertificateGeneratingEventArgs>)

 

void add_CertificateGenerating(EventHandler<CertificateGeneratingEventArgs> value)

 

Sub add_CertificateGenerating(value As EventHandler<CertificateGeneratingEventArgs>)

Parameters:

  • value:

add_Starting

 

method add_Starting(value: EventHandler)

 

void add_Starting(EventHandler value)

 

Sub add_Starting(value As EventHandler)

Parameters:

  • value:

add_Stopped

 

method add_Stopped(value: EventHandler)

 

void add_Stopped(EventHandler value)

 

Sub add_Stopped(value As EventHandler)

Parameters:

  • value:

CreateNetworkServer  protected

 

method CreateNetworkServer(configuration: INetworkServerConfiguration): INetworkServer

 

INetworkServer CreateNetworkServer(INetworkServerConfiguration configuration)

 

Function CreateNetworkServer(configuration As INetworkServerConfiguration) As INetworkServer

Parameters:

  • configuration:

CreateServerMainForm  protected

 

method CreateServerMainForm: Form

 

Form CreateServerMainForm()

 

Function CreateServerMainForm As Form

CreateServerWinService  protected

 

method CreateServerWinService: ServiceBase

 

ServiceBase CreateServerWinService()

 

Function CreateServerWinService As ServiceBase

GetArgumentParser  protected

Returns a default implementation of the IArgumentParser.

If you need more profound logic of handling command-line arguments then you need to create your own implementation of the IArgumentParser interface. In that case you should override current method to make it return the instance of your custom parser.

 

method GetArgumentParser: IArgumentParser

 

IArgumentParser GetArgumentParser()

 

Function GetArgumentParser As IArgumentParser

GetSelfSignedCertificate  protected

 

method GetSelfSignedCertificate: X509Certificate2

 

X509Certificate2 GetSelfSignedCertificate()

 

Function GetSelfSignedCertificate As X509Certificate2

GetStartupOptionsHelpText  protected

Returns help string message.

By default this message contains description of common parameters and content of properties ApplicationInfo, HelpTextFooter, ExtendedParametersHelpText.

This method can be overriden to return custom help text.

 

method GetStartupOptionsHelpText: String

 

String GetStartupOptionsHelpText()

 

Function GetStartupOptionsHelpText As String

LoadApplicationServerConfiguration  protected

 

method LoadApplicationServerConfiguration

 

void LoadApplicationServerConfiguration()

 

Sub LoadApplicationServerConfiguration

OnApplicationServerException  protected

 

method OnApplicationServerException(e: ApplicationServerExceptionEventArgs)

 

void OnApplicationServerException(ApplicationServerExceptionEventArgs e)

 

Sub OnApplicationServerException(e As ApplicationServerExceptionEventArgs)

Parameters:

  • e:

OnCertificateGenerating  protected

 

method OnCertificateGenerating(e: CertificateGeneratingEventArgs)

 

void OnCertificateGenerating(CertificateGeneratingEventArgs e)

 

Sub OnCertificateGenerating(e As CertificateGeneratingEventArgs)

Parameters:

  • e:

OnStarting  protected

 

method OnStarting

 

void OnStarting()

 

Sub OnStarting

OnStopped  protected

 

method OnStopped

 

void OnStopped()

 

Sub OnStopped

ProcessExtendedParameters  protected

If the IArgumentParser encounters command-line parameters it cannot process then this method is called.

By default this method forces application sartup code to show correct command-line options help and to exit.

Override this method to handle custom command-line parameters.

``` protected override void ProcessExtendedParameters() { if (this.ExtendedParameters[0] == "--sample") { // Application-specific actions needed to handle the --sample startup parameter } } </source >

 

method ProcessExtendedParameters

 

void ProcessExtendedParameters()

 

Sub ProcessExtendedParameters

remove_ApplicationServerException

 

method remove_ApplicationServerException(value: EventHandler<ApplicationServerExceptionEventArgs>)

 

void remove_ApplicationServerException(EventHandler<ApplicationServerExceptionEventArgs> value)

 

Sub remove_ApplicationServerException(value As EventHandler<ApplicationServerExceptionEventArgs>)

Parameters:

  • value:

remove_CertificateGenerating

 

method remove_CertificateGenerating(value: EventHandler<CertificateGeneratingEventArgs>)

 

void remove_CertificateGenerating(EventHandler<CertificateGeneratingEventArgs> value)

 

Sub remove_CertificateGenerating(value As EventHandler<CertificateGeneratingEventArgs>)

Parameters:

  • value:

remove_Starting

 

method remove_Starting(value: EventHandler)

 

void remove_Starting(EventHandler value)

 

Sub remove_Starting(value As EventHandler)

Parameters:

  • value:

remove_Stopped

 

method remove_Stopped(value: EventHandler)

 

void remove_Stopped(EventHandler value)

 

Sub remove_Stopped(value As EventHandler)

Parameters:

  • value:

Run

The main application startup entry point.

This method accepts command-line arguments, processes them and starts the application in appropriate mode.

 

method Run(arguments: array of String)

 

void Run(String[] arguments)

 

Sub Run(arguments As array of String)

Parameters:

  • arguments: Startup parameters.

RunAsConsoleApplication  protected

This method is called when command-line application run mode is requested.

This method should perform application startup procedures, f.e. initialize network and database connections etc.

 

method RunAsConsoleApplication

 

void RunAsConsoleApplication()

 

Sub RunAsConsoleApplication

RunAsWindowsApplication  protected

This method is called when GUI-enabled application run mode is requested.

This method should perform application startup procedures, f.e. initialize network and database connections etc and show the main application form, either WinForms, GTK or WPF.

 

method RunAsWindowsApplication

 

void RunAsWindowsApplication()

 

Sub RunAsWindowsApplication

RunAsWindowsService  protected

This method is called when application should be started as Windows Service.

This method should perform application startup procedures, f.e. initialize network and database connections etc.

 

method RunAsWindowsService

 

void RunAsWindowsService()

 

Sub RunAsWindowsService

RunAsWindowsServiceInstaller  protected

 

method RunAsWindowsServiceInstaller

 

void RunAsWindowsServiceInstaller()

 

Sub RunAsWindowsServiceInstaller

RunAsWindowsServiceUninstaller  protected

 

method RunAsWindowsServiceUninstaller

 

void RunAsWindowsServiceUninstaller()

 

Sub RunAsWindowsServiceUninstaller

ShutdownAsConsoleApplication  protected

This method is called when an application running in console mode is shut down.

Override this method to perform application shutdown procedures, f.e. closie network connections, release resources etc.

 

method ShutdownAsConsoleApplication

 

void ShutdownAsConsoleApplication()

 

Sub ShutdownAsConsoleApplication

 

ApplicationServerException

 

event ApplicationServerException: EventHandler<ApplicationServerExceptionEventArgs>;

 

delegate EventHandler<ApplicationServerExceptionEventArgs> ApplicationServerException()

 

Event ApplicationServerException As EventHandler<ApplicationServerExceptionEventArgs>

CertificateGenerating

 

event CertificateGenerating: EventHandler<CertificateGeneratingEventArgs>;

 

delegate EventHandler<CertificateGeneratingEventArgs> CertificateGenerating()

 

Event CertificateGenerating As EventHandler<CertificateGeneratingEventArgs>

Starting

 

event Starting: EventHandler;

 

delegate EventHandler Starting()

 

Event Starting As EventHandler

Stopped

 

event Stopped: EventHandler;

 

delegate EventHandler Stopped()

 

Event Stopped As EventHandler

See Also