PeanutButter
Loading...
Searching...
No Matches
PeanutButter.ServiceShell.Shell Class Referenceabstract

More...

Inheritance diagram for PeanutButter.ServiceShell.Shell:
PeanutButter.ServiceShell.ISimpleLogger

Classes

class  VersionInfo
 Provides basic version information. More...

Public Member Functions

virtual void Log (string status)
 Log a string, as INFO.
virtual void LogDebug (string message)
 Log a debug message.
Parameters
message

virtual void LogInfo (string message)
 Log an info message.
Parameters
message

virtual void LogWarning (string message)
 Log a warning message.
Parameters
message

virtual void LogFatal (string message)
 Log a fatal message - service should probably quit.
Parameters
message

void WaitForIntervalFrom (DateTime lastRun)
 Waits until the next Interval should be fired, taking into account the run-time of the last round.

Static Public Member Functions

static int RunMain< T > (string[] args)
 Runs the service via the given arguments, ie either to affect a required service control operation, or with no arguments, as per the SCM.
static void StartTesting ()
 For testability, this sets the service into "test mode".
static void ShouldHaveRunMainFor< T > (string[] args)
 Tests if the main entry point was run.
static void ResetTestMode ()
 Resets the test mode (this is code to enable testing)

Protected Member Functions

 Shell ()
void RunOnce ()
 Runs the main logic once. You MUST override this in your derived service.
override void OnStart (string[] args)
override void OnStop ()
override void OnPause ()
override void OnShutdown ()
override void OnContinue ()
void Run ()
 Runs the main loop once.
bool Stopped ()
 Test if the service has been stopped. Will block whilst the service is paused.
virtual ILog GetLogger ()
 Provide the ILog logger.

Properties

int Interval [get, protected set]
 Sets the max interval, in seconds, between calls to your implementation of RunOnce Note that this means that if your RunOnce takes longer than this to run, the service will essentially loop your RunOnce non-stop. Only one RunOnce iteration is done at at a time (ie no concurrency)
VersionInfo Version [get]
 The current version of the service.
bool RunningOnceFromCLI [get, set]
 Whether or not the service was invoked from the commandline (as opposed to being invoked via the SCM)
string DisplayName [get, protected set]
 The name displayed for this service in the SCM MMI snap-in (services.msc)
string CopyrightInformation [get, set]
 Copyright information for this service.
new string ServiceName [get, set]
 The short name for the service, typically used to control it via the commandline. This is not the name displayed in services.msc.
ServiceState State [get]
 Reflects the current state of the service.

Detailed Description

Member Function Documentation

◆ GetLogger()

virtual ILog PeanutButter.ServiceShell.Shell.GetLogger ( )
protectedvirtual

Provide the ILog logger.

Returns

◆ Log()

virtual void PeanutButter.ServiceShell.Shell.Log ( string status)
virtual

Log a string, as INFO.

Parameters
status

◆ LogDebug()

virtual void PeanutButter.ServiceShell.Shell.LogDebug ( string message)
virtual

Log a debug message.

Parameters
message

Implements PeanutButter.ServiceShell.ISimpleLogger.

◆ LogFatal()

virtual void PeanutButter.ServiceShell.Shell.LogFatal ( string message)
virtual

Log a fatal message - service should probably quit.

Parameters
message

Implements PeanutButter.ServiceShell.ISimpleLogger.

◆ LogInfo()

virtual void PeanutButter.ServiceShell.Shell.LogInfo ( string message)
virtual

Log an info message.

Parameters
message

Implements PeanutButter.ServiceShell.ISimpleLogger.

◆ LogWarning()

virtual void PeanutButter.ServiceShell.Shell.LogWarning ( string message)
virtual

Log a warning message.

Parameters
message

Implements PeanutButter.ServiceShell.ISimpleLogger.

◆ RunMain< T >()

int PeanutButter.ServiceShell.Shell.RunMain< T > ( string[] args)
static

Runs the service via the given arguments, ie either to affect a required service control operation, or with no arguments, as per the SCM.

Parameters
args
Template Parameters
T
Returns
Type Constraints
T :Shell 
T :new() 

◆ RunOnce()

void PeanutButter.ServiceShell.Shell.RunOnce ( )
abstractprotected

Runs the main logic once. You MUST override this in your derived service.

Exceptions
NotImplementedException

◆ ShouldHaveRunMainFor< T >()

void PeanutButter.ServiceShell.Shell.ShouldHaveRunMainFor< T > ( string[] args)
static

Tests if the main entry point was run.

Parameters
args
Template Parameters
T
Exceptions
ShellTestFailureException

◆ Stopped()

bool PeanutButter.ServiceShell.Shell.Stopped ( )
protected

Test if the service has been stopped. Will block whilst the service is paused.

Returns

◆ WaitForIntervalFrom()

void PeanutButter.ServiceShell.Shell.WaitForIntervalFrom ( DateTime lastRun)

Waits until the next Interval should be fired, taking into account the run-time of the last round.

Parameters
lastRun

Property Documentation

◆ ServiceName

new string PeanutButter.ServiceShell.Shell.ServiceName
getset

The short name for the service, typically used to control it via the commandline. This is not the name displayed in services.msc.

Exceptions
ServiceUnconfiguredException

The documentation for this class was generated from the following file:
  • source/Win32Service/PeanutButter.ServiceShell/Shell.cs