Show / Hide Table of Contents

Class Service

Represents a lightweight service that can be controlled by Start/SignalStop-like commands. This class serves a a base for various implementations (i.e. LogService) including their composites. This class is thread-safe

Inheritance
System.Object
DisposableObject
ApplicationComponent
Service
ErlAbstractNode
NetGate
CompositeServiceHost
Service<TDirector>
WorkItemAggregatorService<TContext>
ThrottlingService
GeoLookupService
NOPMessenger
Implements
IApplicationComponent
System.IDisposable
IService
INamed
IConfigurable
ILocalizedTimeProvider
Inherited Members
ApplicationComponent.AllComponents
ApplicationComponent.GetAppComponentBySID(UInt64)
ApplicationComponent.GetAppComponentByCommonName(String)
ApplicationComponent.ComponentSID
ApplicationComponent.ComponentStartTime
ApplicationComponent.ComponentCommonName
ApplicationComponent.ComponentDirector
DisposableObject.DisposeAndNull<T>(T)
DisposableObject.DisposeStarted
DisposableObject.Disposed
DisposableObject.EnsureObjectNotDisposed()
DisposableObject.Dispose()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: NFX.ServiceModel
Assembly: NFX.dll
Syntax
public abstract class Service : ApplicationComponent, IApplicationComponent, IDisposable, IService, INamed, IConfigurable, ILocalizedTimeProvider

Constructors

Service()

Declaration
protected Service()

Service(Object)

Declaration
protected Service(object director)
Parameters
Type Name Description
System.Object director

Fields

CONFIG_NAME_ATTR

Declaration
public const string CONFIG_NAME_ATTR = "name"
Field Value
Type Description
System.String

Properties

ApplicationDontAutoStartService

Checks whether the class is decorated with ApplicationDontAutoStartServiceAttribute

Declaration
public bool ApplicationDontAutoStartService { get; }
Property Value
Type Description
System.Boolean

LocalizedTime

Returns current time localized per TimeLocation

Declaration
public DateTime LocalizedTime { get; }
Property Value
Type Description
System.DateTime

Name

Provides textual name for the service

Declaration
public string Name { get; protected set; }
Property Value
Type Description
System.String

Running

Returns true when service is active or about to become active. Check in service implementation loops/threads/tasks

Declaration
public bool Running { get; }
Property Value
Type Description
System.Boolean

Status

Current service status

Declaration
public ControlStatus Status { get; }
Property Value
Type Description
ControlStatus

TimeLocation

Returns time location of this LocalizedTimeProvider implementation

Declaration
public TimeLocation TimeLocation { get; set; }
Property Value
Type Description
TimeLocation

Methods

____ObtainPrivateServiceStatusLockObject()

WARNING: Developers never call this method!!! It is used by advanced derived implementations that need to synchronize status updates. We do not want to make statuslock protected as it is almost never needed, hence this accessor

Declaration
protected object ____ObtainPrivateServiceStatusLockObject()
Returns
Type Description
System.Object

AbortStart()

Allows to abort unsuccessful DoStart() overridden implementation. This method must be called from within DoStart()

Declaration
protected void AbortStart()

AcceptManagerVisit(Object, DateTime)

Accepts a visit of a manager entity - this call is useful for periodic updates of service status, i.e. when service does not have a thread of its own it can be periodically managed by some other service through this method. The default implementation of DoAcceptManagerVisit(object, DateTime) does nothing

Declaration
public void AcceptManagerVisit(object manager, DateTime managerNow)
Parameters
Type Name Description
System.Object manager
System.DateTime managerNow

CheckForCompleteStop()

Non-blocking call that returns true when the service instance has completely stopped after SignalStop()

Declaration
public bool CheckForCompleteStop()
Returns
Type Description
System.Boolean

CheckServiceActive()

Checks for service activity and throws exception if service is not in ControlStatus.Active state

Declaration
protected void CheckServiceActive()

CheckServiceActiveOrStarting()

Checks for service activity and throws exception if service is not in ControlStatus.Active state

Declaration
protected void CheckServiceActiveOrStarting()

CheckServiceInactive()

Checks for service inactivity and throws exception if service is running (started, starting or stopping)

Declaration
protected void CheckServiceInactive()

Configure(IConfigSectionNode)

Configures service from configuration node (and possibly it's sub-nodes)

Declaration
public void Configure(IConfigSectionNode fromNode)
Parameters
Type Name Description
IConfigSectionNode fromNode

Destructor()

Declaration
protected override void Destructor()
Overrides
ApplicationComponent.Destructor()

DoAcceptManagerVisit(Object, DateTime)

Accepts a visit from external manager. Base implementation does nothing. Override in services that need external management calls to update their state periodically, i.e. when they don't have a thread on their own

Declaration
protected virtual void DoAcceptManagerVisit(object manager, DateTime managerNow)
Parameters
Type Name Description
System.Object manager
System.DateTime managerNow

DoCheckForCompleteStop()

Provides implementation for checking whether the service has completely stopped

Declaration
protected virtual bool DoCheckForCompleteStop()
Returns
Type Description
System.Boolean

DoConfigure(IConfigSectionNode)

Provides implementation that configures service from configuration node (and possibly it's sub-nodes)

Declaration
protected virtual void DoConfigure(IConfigSectionNode node)
Parameters
Type Name Description
IConfigSectionNode node

DoSignalStop()

Provides implementation that signals service to stop. This is expected not to block

Declaration
protected virtual void DoSignalStop()

DoStart()

Provides implementation that starts the service

Declaration
protected virtual void DoStart()

DoWaitForCompleteStop()

Provides implementation for a blocking call that returns only after a complete service stop

Declaration
protected virtual void DoWaitForCompleteStop()

LocalizedTimeToUniversalTime(DateTime)

Converts localized time to UTC time as of TimeLocation property

Declaration
public DateTime LocalizedTimeToUniversalTime(DateTime local)
Parameters
Type Name Description
System.DateTime local
Returns
Type Description
System.DateTime

SignalStop()

Non-blocking call that initiates the stopping of the service

Declaration
public void SignalStop()

Start()

Blocking call that starts the service instance

Declaration
public void Start()

UniversalTimeToLocalizedTime(DateTime)

Converts universal time to local time as of TimeLocation property

Declaration
public DateTime UniversalTimeToLocalizedTime(DateTime utc)
Parameters
Type Name Description
System.DateTime utc
Returns
Type Description
System.DateTime

WaitForCompleteStop()

Blocks execution of current thread until this service has completely stopped. This call must be performed by only 1 thread otherwise exception is thrown

Declaration
public void WaitForCompleteStop()

Implements

IApplicationComponent
System.IDisposable
IService
INamed
IConfigurable
ILocalizedTimeProvider

Extension Methods

MiscUtils.NonNull<T>(T, Func<Exception>, String)
ObjectValueConversion.AsString(Object, String, ConvertErrorHandling)
ObjectValueConversion.AsNonNullOrEmptyString(Object)
ObjectValueConversion.AsLaconicConfig(Object, ConfigSectionNode, String, ConvertErrorHandling)
ObjectValueConversion.AsJSONConfig(Object, ConfigSectionNode, String, ConvertErrorHandling)
ObjectValueConversion.AsXMLConfig(Object, ConfigSectionNode, ConvertErrorHandling)
ObjectValueConversion.AsChar(Object, Char, ConvertErrorHandling)
ObjectValueConversion.AsNullableChar(Object, Nullable<Char>, ConvertErrorHandling)
ObjectValueConversion.AsByte(Object, Byte, ConvertErrorHandling)
ObjectValueConversion.AsNullableByte(Object, Nullable<Byte>, ConvertErrorHandling)
ObjectValueConversion.AsSByte(Object, SByte, ConvertErrorHandling)
ObjectValueConversion.AsNullableSByte(Object, Nullable<SByte>, ConvertErrorHandling)
ObjectValueConversion.AsShort(Object, Int16, ConvertErrorHandling)
ObjectValueConversion.AsNullableShort(Object, Nullable<Int16>, ConvertErrorHandling)
ObjectValueConversion.AsUShort(Object, UInt16, ConvertErrorHandling)
ObjectValueConversion.AsNullableUShort(Object, Nullable<UInt16>, ConvertErrorHandling)
ObjectValueConversion.AsInt(Object, Int32, ConvertErrorHandling)
ObjectValueConversion.AsNullableInt(Object, Nullable<Int32>, ConvertErrorHandling)
ObjectValueConversion.AsUInt(Object, UInt32, ConvertErrorHandling)
ObjectValueConversion.AsNullableUInt(Object, Nullable<UInt32>, ConvertErrorHandling)
ObjectValueConversion.AsLong(Object, Int64, ConvertErrorHandling)
ObjectValueConversion.AsNullableLong(Object, Nullable<Int64>, ConvertErrorHandling)
ObjectValueConversion.AsULong(Object, UInt64, ConvertErrorHandling)
ObjectValueConversion.AsNullableULong(Object, Nullable<UInt64>, ConvertErrorHandling)
ObjectValueConversion.AsDouble(Object, Double, ConvertErrorHandling)
ObjectValueConversion.AsNullableDouble(Object, Nullable<Double>, ConvertErrorHandling)
ObjectValueConversion.AsFloat(Object, Single, ConvertErrorHandling)
ObjectValueConversion.AsNullableFloat(Object, Nullable<Single>, ConvertErrorHandling)
ObjectValueConversion.AsDecimal(Object, Decimal, ConvertErrorHandling)
ObjectValueConversion.AsNullableDecimal(Object, Nullable<Decimal>, ConvertErrorHandling)
ObjectValueConversion.AsBool(Object, Boolean, ConvertErrorHandling)
ObjectValueConversion.AsNullableBool(Object, Nullable<Boolean>, ConvertErrorHandling)
ObjectValueConversion.AsGUID(Object, Guid, ConvertErrorHandling)
ObjectValueConversion.AsNullableGUID(Object, Nullable<Guid>, ConvertErrorHandling)
ObjectValueConversion.AsDateTime(Object)
ObjectValueConversion.AsDateTime(Object, DateTime, ConvertErrorHandling)
ObjectValueConversion.AsNullableDateTime(Object, Nullable<DateTime>, ConvertErrorHandling)
ObjectValueConversion.AsGDID(Object)
ObjectValueConversion.AsGDID(Object, GDID, ConvertErrorHandling)
ObjectValueConversion.AsNullableGDID(Object, Nullable<GDID>, ConvertErrorHandling)
ObjectValueConversion.AsGDIDSymbol(Object)
ObjectValueConversion.AsGDIDSymbol(Object, GDIDSymbol, ConvertErrorHandling)
ObjectValueConversion.AsNullableGDIDSymbol(Object, Nullable<GDIDSymbol>, ConvertErrorHandling)
ObjectValueConversion.AsTimeSpan(Object)
ObjectValueConversion.AsTimeSpan(Object, TimeSpan, ConvertErrorHandling)
ObjectValueConversion.AsNullableTimeSpan(Object, Nullable<TimeSpan>, ConvertErrorHandling)
ObjectValueConversion.AsEnum<TEnum>(Object, TEnum, ConvertErrorHandling)
ObjectValueConversion.AsNullableEnum<TEnum>(Object, Nullable<TEnum>, ConvertErrorHandling)
ObjectValueConversion.AsUri(Object, Uri, ConvertErrorHandling)
JSONExtensions.ToJSON(Object, JSONWritingOptions)
JSONExtensions.ToJSON(Object, TextWriter, JSONWritingOptions)
JSONExtensions.ToJSON(Object, Stream, JSONWritingOptions, Encoding)
ErlObject.ToErlObject(Object)
ErlObject.ToErlObject(Object, ErlTypeOrder, Boolean)
Back to top Copyright © 2006-2018 Agnicore Inc
Generated by DocFX