Service

Overview

The Service base class provides a base implementation that can (but need not) be used as the ancestor for your custom service implementations. This class implements the IActivatableService, IChannelAwareService, IDisposableService and IRolesAwareService interfaces and provides access to the session and event sink management architecture.

Note: While this class is not marked as abstract it cannot be instantiated and used directly.

Location


 

constructor  protected

Creates a new instance of the Service class.

 

constructor

 

Service()

 

Sub New()

constructor (ISessionManager)  protected

Creates a new instance of the Service class and sets the session manager and event sink manager instances that will be used later by the service methods.

 

constructor(sessionManager: ISessionManager)

 

Service(ISessionManager sessionManager)

 

Sub New(sessionManager As ISessionManager)

Parameters:

  • sessionManager: Session manager instance

constructor (ISessionManager, IEventSinkManager)  protected beta

Creates a new instance of the Service class and sets the session manager and event sink manager instances that will be used later by the service methods.

 

constructor(sessionManager: ISessionManager; eventManager: IEventSinkManager)

 

Service(ISessionManager sessionManager, IEventSinkManager eventManager)

 

Sub New(sessionManager As ISessionManager, eventManager As IEventSinkManager)

Parameters:

  • sessionManager: Session manager instance
  • eventManager: Event sink manager instance

Activate

 

method Activate(clientId: Guid; enforceSessionCheck: Boolean; roles: nullable array of String)

 

void Activate(Guid clientId, Boolean enforceSessionCheck, String[]? roles)

 

Sub Activate(clientId As Guid, enforceSessionCheck As Boolean, roles As String()?)

Parameters:

  • clientId:
  • enforceSessionCheck:
  • roles:

AfterActivate

This event is raised after the service instance has been activated. This event can be used to perform additional service initialization tasks.

 

event AfterActivate: EventHandler<ServiceActivationEventArgs>;

 

delegate EventHandler<ServiceActivationEventArgs> AfterActivate()

 

Event AfterActivate As EventHandler<ServiceActivationEventArgs>

AfterDeactivate

This event is raised after the service instance has been deactivated. This event can be used to perform additional cleanup tasks.

 

event AfterDeactivate: EventHandler<ServiceActivationEventArgs>;

 

delegate EventHandler<ServiceActivationEventArgs> AfterDeactivate()

 

Event AfterDeactivate As EventHandler<ServiceActivationEventArgs>

BeforeActivate

This event is raised before the service instance will be activated. This event can be used to check additional service activation conditions.

 

event BeforeActivate: EventHandler<ServiceActivationEventArgs>;

 

delegate EventHandler<ServiceActivationEventArgs> BeforeActivate()

 

Event BeforeActivate As EventHandler<ServiceActivationEventArgs>

BeforeDeactivate

This event is raised before the service instance will be deactivated. This event can be used to perform additional cleanup tasks.

 

event BeforeDeactivate: EventHandler<ServiceActivationEventArgs>;

 

delegate EventHandler<ServiceActivationEventArgs> BeforeDeactivate()

 

Event BeforeDeactivate As EventHandler<ServiceActivationEventArgs>

CanBeDisposed

Get a flag indicating whether the current service instance can be disposed after servicing the request.

 

property CanBeDisposed: Boolean read;

 

Boolean CanBeDisposed { get; }

 

ReadOnly Property CanBeDisposed() As Boolean

Deactivate

Deactivates the service instance.

This method raises the BeforeDeactivate and AfterDeactivate events and releases the service session.

 

method Deactivate(clientId: Guid)

 

void Deactivate(Guid clientId)

 

Sub Deactivate(clientId As Guid)

Parameters:

  • clientId: Session Id

DestroySession  protected

Destroys and disposes the current session.

This method is widely used in the login services to destroy the user session after logout or in case the login attempt was not successful.

 

method DestroySession

 

void DestroySession()

 

Sub DestroySession()

EventSinkManager  protected

Provides access to the event sink manager that should be used by the service methods.

 

property EventSinkManager: IEventSinkManager read;

 

IEventSinkManager EventSinkManager { get; }

 

ReadOnly Property EventSinkManager() As IEventSinkManager

GetEventSink (Type): IROEventSink

Obtains an event sink proxy for the specified interface.

 

method GetEventSink(eventSink: Type): IROEventSink

 

IROEventSink GetEventSink(Type eventSink)

 

Function GetEventSink(eventSink As Type) As IROEventSink

Parameters:

  • eventSink: Event sink type

GetEventSink (Type, IEventTargets): IROEventSink

Obtains an event sink proxy for the specified interface. This method allows to manage the event recipients.

 

method GetEventSink(eventSink: Type; eventTargets: IEventTargets): IROEventSink

 

IROEventSink GetEventSink(Type eventSink, IEventTargets eventTargets)

 

Function GetEventSink(eventSink As Type, eventTargets As IEventTargets) As IROEventSink

Parameters:

  • eventSink: Event sink type
  • eventTargets: Event recepients

GetEventSink (Type, array of Guid): IROEventSink

Obtains an event sink proxy for the specified interface. This method allows to set the event recipients.

 

method GetEventSink(eventSink: Type; recipients: array of Guid): IROEventSink

 

IROEventSink GetEventSink(Type eventSink, Guid[] recipients)

 

Function GetEventSink(eventSink As Type, recipients As Guid()) As IROEventSink

Parameters:

  • eventSink: Event sink type
  • recipients: Event recipients

GetEventSink<T>

 

method GetEventSink<T>: T

 

T GetEventSink<T>()

 

Function GetEventSink<T>() As T

GetEventSink<T> (IEventTargets): T

 

method GetEventSink<T>(eventTargets: IEventTargets): T

 

T GetEventSink<T>(IEventTargets eventTargets)

 

Function GetEventSink<T>(eventTargets As IEventTargets) As T

Parameters:

  • eventTargets:

GetEventSink<T> (array of Guid): T

 

method GetEventSink<T>(recipients: array of Guid): T

 

T GetEventSink<T>(Guid[] recipients)

 

Function GetEventSink<T>(recipients As Guid()) As T

Parameters:

  • recipients:

GetSession  protected

Gets the service session. Unlike the Session property this method returns null instead of throwing an exception in case the SessionManager is not set.

 

method GetSession: ISession

 

ISession GetSession()

 

Function GetSession() As ISession

HasSession

Gets a flag indicating whether a session is accessible (ie SessionManager is set and the session itself exists for the current remote client)

 

property HasSession: Boolean read;

 

Boolean HasSession { get; }

 

ReadOnly Property HasSession() As Boolean

IsActive

 

property IsActive: Boolean read;

 

Boolean IsActive { get; }

 

ReadOnly Property IsActive() As Boolean

RequireSession

Gets or sets a flag ingicating wheter accessing this service methods remotely requres an existing session.

 

property RequireSession: Boolean read write;

 

Boolean RequireSession { get; set; }

 

Property RequireSession() As Boolean

Roles

 

property Roles: array of String read write;

 

String[] Roles { get; set; }

 

Property Roles() As String()

ServerChannel

Gets a IServerChannelInfo instance providing information about the server channel used to call the service method remotely.

 

property ServerChannel: IServerChannelInfo read;

 

IServerChannelInfo ServerChannel { get; }

 

ReadOnly Property ServerChannel() As IServerChannelInfo

ServiceActivationException

 

event ServiceActivationException: EventHandler<ServiceActivationExceptionEventArgs>;

 

delegate EventHandler<ServiceActivationExceptionEventArgs> ServiceActivationException()

 

Event ServiceActivationException As EventHandler<ServiceActivationExceptionEventArgs>

ServiceMethodException

 

event ServiceMethodException: EventHandler<ServiceMethodExceptionEventArgs>;

 

delegate EventHandler<ServiceMethodExceptionEventArgs> ServiceMethodException()

 

Event ServiceMethodException As EventHandler<ServiceMethodExceptionEventArgs>

ServiceValidateRoles

Validates the service roles. This method is used by the service invoker methods to validate the server access roles.

See the IRolesAwareService interface description for more details.

 

method ServiceValidateRoles(requiredRoles: array of String)

 

void ServiceValidateRoles(String[] requiredRoles)

 

Sub ServiceValidateRoles(requiredRoles As String())

Parameters:

  • requiredRoles: Required service roles

Session

Provides access to the Session for the current remote client. In case when session doesn't exist for the current client yet, a new session will be created when the Session property is accessed (but not before).

 

property Session: ISession read write;

 

ISession Session { get; set; }

 

Property Session() As ISession

SessionID

Gets the Session ID (aka remote client Id) for the request that is currently being executed.

 

property SessionID: Guid read;

 

Guid SessionID { get; }

 

ReadOnly Property SessionID() As Guid

SessionManager  protected

Provides access to the session manager that is used by the service.

 

property SessionManager: ISessionManager read;

 

ISessionManager SessionManager { get; }

 

ReadOnly Property SessionManager() As ISessionManager

SubscribeClientEventSink

This method registers the current client as receiver of the provided events type.

 

method SubscribeClientEventSink(eventSink: Type)

 

void SubscribeClientEventSink(Type eventSink)

 

Sub SubscribeClientEventSink(eventSink As Type)

Parameters:

  • eventSink: Event sink type

TriggerAfterActivate  protected

Raises the AfterActivate event.

 

method TriggerAfterActivate(sessionId: Guid)

 

void TriggerAfterActivate(Guid sessionId)

 

Sub TriggerAfterActivate(sessionId As Guid)

Parameters:

  • sessionId: Session Id

TriggerAfterDeactivate  protected

Raises the AfterDeactivate event.

 

method TriggerAfterDeactivate(sessionId: Guid)

 

void TriggerAfterDeactivate(Guid sessionId)

 

Sub TriggerAfterDeactivate(sessionId As Guid)

Parameters:

  • sessionId: Session Id

TriggerBeforeActivate  protected

Raises the BeforeActivate event.

 

method TriggerBeforeActivate(sessionId: Guid)

 

void TriggerBeforeActivate(Guid sessionId)

 

Sub TriggerBeforeActivate(sessionId As Guid)

Parameters:

  • sessionId: Session Id

TriggerBeforeDeactivate  protected

Raises the BeforeDeactivate event.

 

method TriggerBeforeDeactivate(sessionId: Guid)

 

void TriggerBeforeDeactivate(Guid sessionId)

 

Sub TriggerBeforeDeactivate(sessionId As Guid)

Parameters:

  • sessionId: Session Id

TriggerValidateRoles  protected

Raises the ValidateRoles event and returns the roles check result.

 

method TriggerValidateRoles(roles: array of String; allowByDefault: Boolean): Boolean

 

Boolean TriggerValidateRoles(String[] roles, Boolean allowByDefault)

 

Function TriggerValidateRoles(roles As String(), allowByDefault As Boolean) As Boolean

Parameters:

  • roles: Required servcie roles
  • allowByDefault: Default result returned when there are no event handlers for the ValidateRoles event

UnsubscribeClientEventSink

This method unregisters the current client as receiver of the any events.

 

method UnsubscribeClientEventSink

 

void UnsubscribeClientEventSink()

 

Sub UnsubscribeClientEventSink()

UnsubscribeClientEventSink (Type)

This method unregisters the current client as receiver of the provided events type.

 

method UnsubscribeClientEventSink(eventSink: Type)

 

void UnsubscribeClientEventSink(Type eventSink)

 

Sub UnsubscribeClientEventSink(eventSink As Type)

Parameters:

  • eventSink: Event sink type

ValidateRoles

This event is triggered for methods that have roles set and can be used to override the default roles check procedure.

 

event ValidateRoles: EventHandler<ValidateRolesEventArgs>;

 

delegate EventHandler<ValidateRolesEventArgs> ValidateRoles()

 

Event ValidateRoles As EventHandler<ValidateRolesEventArgs>

 

CanBeDisposed

Get a flag indicating whether the current service instance can be disposed after servicing the request.

 

property CanBeDisposed: Boolean read;

 

Boolean CanBeDisposed { get; }

 

ReadOnly Property CanBeDisposed() As Boolean

EventSinkManager  protected

Provides access to the event sink manager that should be used by the service methods.

 

property EventSinkManager: IEventSinkManager read;

 

IEventSinkManager EventSinkManager { get; }

 

ReadOnly Property EventSinkManager() As IEventSinkManager

HasSession

Gets a flag indicating whether a session is accessible (ie SessionManager is set and the session itself exists for the current remote client)

 

property HasSession: Boolean read;

 

Boolean HasSession { get; }

 

ReadOnly Property HasSession() As Boolean

IsActive

 

property IsActive: Boolean read;

 

Boolean IsActive { get; }

 

ReadOnly Property IsActive() As Boolean

RequireSession

Gets or sets a flag ingicating wheter accessing this service methods remotely requres an existing session.

 

property RequireSession: Boolean read write;

 

Boolean RequireSession { get; set; }

 

Property RequireSession() As Boolean

Roles

 

property Roles: array of String read write;

 

String[] Roles { get; set; }

 

Property Roles() As String()

ServerChannel

Gets a IServerChannelInfo instance providing information about the server channel used to call the service method remotely.

 

property ServerChannel: IServerChannelInfo read;

 

IServerChannelInfo ServerChannel { get; }

 

ReadOnly Property ServerChannel() As IServerChannelInfo

Session

Provides access to the Session for the current remote client. In case when session doesn't exist for the current client yet, a new session will be created when the Session property is accessed (but not before).

 

property Session: ISession read write;

 

ISession Session { get; set; }

 

Property Session() As ISession

SessionID

Gets the Session ID (aka remote client Id) for the request that is currently being executed.

 

property SessionID: Guid read;

 

Guid SessionID { get; }

 

ReadOnly Property SessionID() As Guid

SessionManager  protected

Provides access to the session manager that is used by the service.

 

property SessionManager: ISessionManager read;

 

ISessionManager SessionManager { get; }

 

ReadOnly Property SessionManager() As ISessionManager

 

constructor  protected

Creates a new instance of the Service class.

 

constructor

 

Service()

 

Sub New()

constructor (ISessionManager)  protected

Creates a new instance of the Service class and sets the session manager and event sink manager instances that will be used later by the service methods.

 

constructor(sessionManager: ISessionManager)

 

Service(ISessionManager sessionManager)

 

Sub New(sessionManager As ISessionManager)

Parameters:

  • sessionManager: Session manager instance

constructor (ISessionManager, IEventSinkManager)  protected beta

Creates a new instance of the Service class and sets the session manager and event sink manager instances that will be used later by the service methods.

 

constructor(sessionManager: ISessionManager; eventManager: IEventSinkManager)

 

Service(ISessionManager sessionManager, IEventSinkManager eventManager)

 

Sub New(sessionManager As ISessionManager, eventManager As IEventSinkManager)

Parameters:

  • sessionManager: Session manager instance
  • eventManager: Event sink manager instance

Activate

 

method Activate(clientId: Guid; enforceSessionCheck: Boolean; roles: nullable array of String)

 

void Activate(Guid clientId, Boolean enforceSessionCheck, String[]? roles)

 

Sub Activate(clientId As Guid, enforceSessionCheck As Boolean, roles As String()?)

Parameters:

  • clientId:
  • enforceSessionCheck:
  • roles:

Deactivate

Deactivates the service instance.

This method raises the BeforeDeactivate and AfterDeactivate events and releases the service session.

 

method Deactivate(clientId: Guid)

 

void Deactivate(Guid clientId)

 

Sub Deactivate(clientId As Guid)

Parameters:

  • clientId: Session Id

DestroySession  protected

Destroys and disposes the current session.

This method is widely used in the login services to destroy the user session after logout or in case the login attempt was not successful.

 

method DestroySession

 

void DestroySession()

 

Sub DestroySession()

GetEventSink (Type): IROEventSink

Obtains an event sink proxy for the specified interface.

 

method GetEventSink(eventSink: Type): IROEventSink

 

IROEventSink GetEventSink(Type eventSink)

 

Function GetEventSink(eventSink As Type) As IROEventSink

Parameters:

  • eventSink: Event sink type

GetEventSink (Type, IEventTargets): IROEventSink

Obtains an event sink proxy for the specified interface. This method allows to manage the event recipients.

 

method GetEventSink(eventSink: Type; eventTargets: IEventTargets): IROEventSink

 

IROEventSink GetEventSink(Type eventSink, IEventTargets eventTargets)

 

Function GetEventSink(eventSink As Type, eventTargets As IEventTargets) As IROEventSink

Parameters:

  • eventSink: Event sink type
  • eventTargets: Event recepients

GetEventSink (Type, array of Guid): IROEventSink

Obtains an event sink proxy for the specified interface. This method allows to set the event recipients.

 

method GetEventSink(eventSink: Type; recipients: array of Guid): IROEventSink

 

IROEventSink GetEventSink(Type eventSink, Guid[] recipients)

 

Function GetEventSink(eventSink As Type, recipients As Guid()) As IROEventSink

Parameters:

  • eventSink: Event sink type
  • recipients: Event recipients

GetEventSink<T>

 

method GetEventSink<T>: T

 

T GetEventSink<T>()

 

Function GetEventSink<T>() As T

GetEventSink<T> (IEventTargets): T

 

method GetEventSink<T>(eventTargets: IEventTargets): T

 

T GetEventSink<T>(IEventTargets eventTargets)

 

Function GetEventSink<T>(eventTargets As IEventTargets) As T

Parameters:

  • eventTargets:

GetEventSink<T> (array of Guid): T

 

method GetEventSink<T>(recipients: array of Guid): T

 

T GetEventSink<T>(Guid[] recipients)

 

Function GetEventSink<T>(recipients As Guid()) As T

Parameters:

  • recipients:

GetSession  protected

Gets the service session. Unlike the Session property this method returns null instead of throwing an exception in case the SessionManager is not set.

 

method GetSession: ISession

 

ISession GetSession()

 

Function GetSession() As ISession

ServiceValidateRoles

Validates the service roles. This method is used by the service invoker methods to validate the server access roles.

See the IRolesAwareService interface description for more details.

 

method ServiceValidateRoles(requiredRoles: array of String)

 

void ServiceValidateRoles(String[] requiredRoles)

 

Sub ServiceValidateRoles(requiredRoles As String())

Parameters:

  • requiredRoles: Required service roles

SubscribeClientEventSink

This method registers the current client as receiver of the provided events type.

 

method SubscribeClientEventSink(eventSink: Type)

 

void SubscribeClientEventSink(Type eventSink)

 

Sub SubscribeClientEventSink(eventSink As Type)

Parameters:

  • eventSink: Event sink type

TriggerAfterActivate  protected

Raises the AfterActivate event.

 

method TriggerAfterActivate(sessionId: Guid)

 

void TriggerAfterActivate(Guid sessionId)

 

Sub TriggerAfterActivate(sessionId As Guid)

Parameters:

  • sessionId: Session Id

TriggerAfterDeactivate  protected

Raises the AfterDeactivate event.

 

method TriggerAfterDeactivate(sessionId: Guid)

 

void TriggerAfterDeactivate(Guid sessionId)

 

Sub TriggerAfterDeactivate(sessionId As Guid)

Parameters:

  • sessionId: Session Id

TriggerBeforeActivate  protected

Raises the BeforeActivate event.

 

method TriggerBeforeActivate(sessionId: Guid)

 

void TriggerBeforeActivate(Guid sessionId)

 

Sub TriggerBeforeActivate(sessionId As Guid)

Parameters:

  • sessionId: Session Id

TriggerBeforeDeactivate  protected

Raises the BeforeDeactivate event.

 

method TriggerBeforeDeactivate(sessionId: Guid)

 

void TriggerBeforeDeactivate(Guid sessionId)

 

Sub TriggerBeforeDeactivate(sessionId As Guid)

Parameters:

  • sessionId: Session Id

TriggerValidateRoles  protected

Raises the ValidateRoles event and returns the roles check result.

 

method TriggerValidateRoles(roles: array of String; allowByDefault: Boolean): Boolean

 

Boolean TriggerValidateRoles(String[] roles, Boolean allowByDefault)

 

Function TriggerValidateRoles(roles As String(), allowByDefault As Boolean) As Boolean

Parameters:

  • roles: Required servcie roles
  • allowByDefault: Default result returned when there are no event handlers for the ValidateRoles event

UnsubscribeClientEventSink

This method unregisters the current client as receiver of the any events.

 

method UnsubscribeClientEventSink

 

void UnsubscribeClientEventSink()

 

Sub UnsubscribeClientEventSink()

UnsubscribeClientEventSink (Type)

This method unregisters the current client as receiver of the provided events type.

 

method UnsubscribeClientEventSink(eventSink: Type)

 

void UnsubscribeClientEventSink(Type eventSink)

 

Sub UnsubscribeClientEventSink(eventSink As Type)

Parameters:

  • eventSink: Event sink type

 

AfterActivate

This event is raised after the service instance has been activated. This event can be used to perform additional service initialization tasks.

 

event AfterActivate: EventHandler<ServiceActivationEventArgs>;

 

delegate EventHandler<ServiceActivationEventArgs> AfterActivate()

 

Event AfterActivate As EventHandler<ServiceActivationEventArgs>

AfterDeactivate

This event is raised after the service instance has been deactivated. This event can be used to perform additional cleanup tasks.

 

event AfterDeactivate: EventHandler<ServiceActivationEventArgs>;

 

delegate EventHandler<ServiceActivationEventArgs> AfterDeactivate()

 

Event AfterDeactivate As EventHandler<ServiceActivationEventArgs>

BeforeActivate

This event is raised before the service instance will be activated. This event can be used to check additional service activation conditions.

 

event BeforeActivate: EventHandler<ServiceActivationEventArgs>;

 

delegate EventHandler<ServiceActivationEventArgs> BeforeActivate()

 

Event BeforeActivate As EventHandler<ServiceActivationEventArgs>

BeforeDeactivate

This event is raised before the service instance will be deactivated. This event can be used to perform additional cleanup tasks.

 

event BeforeDeactivate: EventHandler<ServiceActivationEventArgs>;

 

delegate EventHandler<ServiceActivationEventArgs> BeforeDeactivate()

 

Event BeforeDeactivate As EventHandler<ServiceActivationEventArgs>

ServiceActivationException

 

event ServiceActivationException: EventHandler<ServiceActivationExceptionEventArgs>;

 

delegate EventHandler<ServiceActivationExceptionEventArgs> ServiceActivationException()

 

Event ServiceActivationException As EventHandler<ServiceActivationExceptionEventArgs>

ServiceMethodException

 

event ServiceMethodException: EventHandler<ServiceMethodExceptionEventArgs>;

 

delegate EventHandler<ServiceMethodExceptionEventArgs> ServiceMethodException()

 

Event ServiceMethodException As EventHandler<ServiceMethodExceptionEventArgs>

ValidateRoles

This event is triggered for methods that have roles set and can be used to override the default roles check procedure.

 

event ValidateRoles: EventHandler<ValidateRolesEventArgs>;

 

delegate EventHandler<ValidateRolesEventArgs> ValidateRoles()

 

Event ValidateRoles As EventHandler<ValidateRolesEventArgs>