ScriptContext
Overview
The ScriptContext class is used inside Data Abstract and implements the IScriptContext, IScriptSession and IServerScriptContext interfaces.
It is used during script runtime for retrieving context data, such as the current session, the parameters of the database connection, the current schema and the roles of current session. Acccess to this environment data may be useful during script interpretation.
Location
- Reference: RemObjects.DataAbstract.Server.dll
- Namespace: RemObjects.DataAbstract.Server
constructor
Creates a new instance of the ScriptContext class. Sets the session of the context and the Data Abstract service as owner.
constructor(owner: DataAbstractService; session: ISession)
ScriptContext(DataAbstractService owner, ISession session)
Sub New(owner As DataAbstractService, session As ISession)
Parameters:
- owner: Service instance that is considered to be the owner of the new script context
- session: Current session of the new script context
AddRole
Adds the specified role name to the roles array of the current session.
Implementation of the IScriptSession interface.
method AddRole(role: String)
void AddRole(String role)
Sub AddRole(role As String)
Parameters:
- role: Role name to add
ApplyChanges
Stub for the implementation of the IServerScriptContext interface.
Parameters:
- delta:
Available
property Available: Boolean read;
Boolean Available { get; }
ReadOnly Property Available() As Boolean
ChangeSession
Replaces the current session with an input one.
method ChangeSession(session: ISession)
void ChangeSession(ISession session)
Sub ChangeSession(session As ISession)
Parameters:
- session: New session
ConnectionCount
Returns the number of database connection definitions in the ConnectionManager.
Implementation of the IServerScriptContext interface.
property ConnectionCount: Int32 read;
Int32 ConnectionCount { get; }
ReadOnly Property ConnectionCount() As Int32
CreateCommandAdapter
method CreateCommandAdapter: BaseCommand
BaseCommand CreateCommandAdapter()
Function CreateCommandAdapter() As BaseCommand
CreateDataAdapter
method CreateDataAdapter: DataAdapter
DataAdapter CreateDataAdapter()
Function CreateDataAdapter() As DataAdapter
CurrentConnection
Returns a connection that is marked as current in the ConnectionManager instance.
Implementation of the IServerScriptContext interface.
property CurrentConnection: Int32 read write;
Int32 CurrentConnection { get; set; }
Property CurrentConnection() As Int32
CurrentConnectionName
Returns the name of the connection that is marked as current in the ConnectionManager instance.
If the string is empty, the service will acquire the connection marked as default.
Implementation of the IServerScriptContext interface.
property CurrentConnectionName: String read write;
String CurrentConnectionName { get; set; }
Property CurrentConnectionName() As String
CurrentConnectionString
The connection string for the connection marked as current in the ConnectionManager. Connection strings are in the format:
<Driver Name>?<Param1>=<Value1>;<Param2>=<Value2>;...
Implementation of the IServerScriptContext interface.
property CurrentConnectionString: String read;
String CurrentConnectionString { get; }
ReadOnly Property CurrentConnectionString() As String
CurrentConnectionType
Returns the type of the connection from the ConnectionManager instance marked as current.
Implementation of the IServerScriptContext interface.
property CurrentConnectionType: String read;
String CurrentConnectionType { get; }
ReadOnly Property CurrentConnectionType() As String
Expired
Indicates whether the session has expired.
This Boolean flag is used by the Session Manager to regularly determine which sessions have expired and can thus be removed.
property Expired: Boolean read;
Boolean Expired { get; }
ReadOnly Property Expired() As Boolean
Fetch (String, array of DataParameter): IDataReader
Stub for the implementation of the IServerScriptContext interface.
method Fetch(sql: String; parameters: array of DataParameter): IDataReader
IDataReader Fetch(String sql, DataParameter[] parameters)
Function Fetch(sql As String, parameters As DataParameter()) As IDataReader
Parameters:
- sql:
- parameters:
Fetch (String, array of String, String, array of DataParameter): IDataReader
Stub for the implementation of the IServerScriptContext interface.
method Fetch(tableName: String; fields: array of String; whereClause: String; parameters: array of DataParameter): IDataReader
IDataReader Fetch(String tableName, String[] fields, String whereClause, DataParameter[] parameters)
Function Fetch(tableName As String, fields As String(), whereClause As String, parameters As DataParameter()) As IDataReader
Parameters:
- tableName:
- fields:
- whereClause:
- parameters:
GetConnectionName
Gets the connection name from the ConnectionManager.ConnectionDefinitions item at the specified index.
Implementation of the IServerScriptContext interface.
method GetConnectionName(index: Int32): String
String GetConnectionName(Int32 index)
Function GetConnectionName(index As Int32) As String
Parameters:
- index: Index of the ConnectionDefinition whose name is required
GetConnectionString
Gets the connection string from the ConnectionManager.ConnectionDefinitions item at the specified index.
Implementation of the IServerScriptContext interface.
method GetConnectionString(index: Int32): String
String GetConnectionString(Int32 index)
Function GetConnectionString(index As Int32) As String
Parameters:
- index: Index of the ConnectionDefinition whose connection string is required
GetConnectionType
Gets the connection type from the ConnectionManager.ConnectionDefinitions item at the specified index.
Implementation of the IServerScriptContext interface.
method GetConnectionType(index: Int32): String
String GetConnectionType(Int32 index)
Function GetConnectionType(index As Int32) As String
Parameters:
- index: Index of the ConnectionDefinition whose connection type is required
HasRole
Determines whether the current session contains the role with the specified name.
Implementation of the IScriptSession interface.
method HasRole(role: String): Boolean
Boolean HasRole(String role)
Function HasRole(role As String) As Boolean
Parameters:
- role: Role key to be located in the session
ID
Returns the ID of the current session. Gets this property from the associated session.
Implementation of the IScriptSession interface.
property ID: String read;
String ID { get; }
ReadOnly Property ID() As String
IsServer
Implementation of the IScriptContext IsServer property. Always returns true.
property IsServer: Boolean read;
Boolean IsServer { get; }
ReadOnly Property IsServer() As Boolean
Item
Gets or sets the value of the parameter with the aKey
name from the session that is associated with this context.
Implementation of the IScriptSession interface.
property Item[name: String]: Object read write;
Object Item[String name] { get; set; }
Property Item(name As String) As Object
Names
property Names: ReadOnlyCollection<String> read;
ReadOnlyCollection<String> Names { get; }
ReadOnly Property Names() As ReadOnlyCollection<String>
New
Implementation of the IScriptSession interface. Always returns false.
property New: Boolean read;
Boolean New { get; }
ReadOnly Property New() As Boolean
RemoveRole
Removes the role with the specified name from the current session.
Implementation of the IScriptSession interface.
method RemoveRole(role: String)
void RemoveRole(String role)
Sub RemoveRole(role As String)
Parameters:
- role: Role name to remove
Roles
This property gives access to the roles associated with the related session; these are checked when services or methods have their Roles property set in the Service Builder.
Implementation of the IScriptSession interface.
property Roles: array of String read write;
String[] Roles { get; set; }
Property Roles() As String()
Schema
Returns an instance of the Schema in which all the data elements it handles are defined. The schema instance is returned form the parent DataAbstractService.
property Schema: Schema read;
Schema Schema { get; }
ReadOnly Property Schema() As Schema
Session
Returns the instance of current session related to the script context. In actuality, it returns a reference to the current ScriptContext instance (this). This can be done because the ScriptContext implements the IScriptSession interface by wrapping the respective methods and properties of the current session, referenced by context class.
property Session: IScriptSession read;
IScriptSession Session { get; }
ReadOnly Property Session() As IScriptSession
Timeout
Indicates the timeout (in seconds) that can elapse before the session will expire, starting at the last access.
When the session is created, this value is initialized from the Timeout setting in the SessionManager component. However, this value can later be changed to extend or shorten the lifetime of the session.
Implementation of the IScriptSession interface.
property Timeout: Int32 read;
Int32 Timeout { get; }
ReadOnly Property Timeout() As Int32
Available
property Available: Boolean read;
Boolean Available { get; }
ReadOnly Property Available() As Boolean
ConnectionCount
Returns the number of database connection definitions in the ConnectionManager.
Implementation of the IServerScriptContext interface.
property ConnectionCount: Int32 read;
Int32 ConnectionCount { get; }
ReadOnly Property ConnectionCount() As Int32
CurrentConnection
Returns a connection that is marked as current in the ConnectionManager instance.
Implementation of the IServerScriptContext interface.
property CurrentConnection: Int32 read write;
Int32 CurrentConnection { get; set; }
Property CurrentConnection() As Int32
CurrentConnectionName
Returns the name of the connection that is marked as current in the ConnectionManager instance.
If the string is empty, the service will acquire the connection marked as default.
Implementation of the IServerScriptContext interface.
property CurrentConnectionName: String read write;
String CurrentConnectionName { get; set; }
Property CurrentConnectionName() As String
CurrentConnectionString
The connection string for the connection marked as current in the ConnectionManager. Connection strings are in the format:
<Driver Name>?<Param1>=<Value1>;<Param2>=<Value2>;...
Implementation of the IServerScriptContext interface.
property CurrentConnectionString: String read;
String CurrentConnectionString { get; }
ReadOnly Property CurrentConnectionString() As String
CurrentConnectionType
Returns the type of the connection from the ConnectionManager instance marked as current.
Implementation of the IServerScriptContext interface.
property CurrentConnectionType: String read;
String CurrentConnectionType { get; }
ReadOnly Property CurrentConnectionType() As String
Expired
Indicates whether the session has expired.
This Boolean flag is used by the Session Manager to regularly determine which sessions have expired and can thus be removed.
property Expired: Boolean read;
Boolean Expired { get; }
ReadOnly Property Expired() As Boolean
ID
Returns the ID of the current session. Gets this property from the associated session.
Implementation of the IScriptSession interface.
property ID: String read;
String ID { get; }
ReadOnly Property ID() As String
IsServer
Implementation of the IScriptContext IsServer property. Always returns true.
property IsServer: Boolean read;
Boolean IsServer { get; }
ReadOnly Property IsServer() As Boolean
Item
Gets or sets the value of the parameter with the aKey
name from the session that is associated with this context.
Implementation of the IScriptSession interface.
property Item[name: String]: Object read write;
Object Item[String name] { get; set; }
Property Item(name As String) As Object
Names
property Names: ReadOnlyCollection<String> read;
ReadOnlyCollection<String> Names { get; }
ReadOnly Property Names() As ReadOnlyCollection<String>
New
Implementation of the IScriptSession interface. Always returns false.
property New: Boolean read;
Boolean New { get; }
ReadOnly Property New() As Boolean
Roles
This property gives access to the roles associated with the related session; these are checked when services or methods have their Roles property set in the Service Builder.
Implementation of the IScriptSession interface.
property Roles: array of String read write;
String[] Roles { get; set; }
Property Roles() As String()
Schema
Returns an instance of the Schema in which all the data elements it handles are defined. The schema instance is returned form the parent DataAbstractService.
property Schema: Schema read;
Schema Schema { get; }
ReadOnly Property Schema() As Schema
Session
Returns the instance of current session related to the script context. In actuality, it returns a reference to the current ScriptContext instance (this). This can be done because the ScriptContext implements the IScriptSession interface by wrapping the respective methods and properties of the current session, referenced by context class.
property Session: IScriptSession read;
IScriptSession Session { get; }
ReadOnly Property Session() As IScriptSession
Timeout
Indicates the timeout (in seconds) that can elapse before the session will expire, starting at the last access.
When the session is created, this value is initialized from the Timeout setting in the SessionManager component. However, this value can later be changed to extend or shorten the lifetime of the session.
Implementation of the IScriptSession interface.
property Timeout: Int32 read;
Int32 Timeout { get; }
ReadOnly Property Timeout() As Int32
constructor
Creates a new instance of the ScriptContext class. Sets the session of the context and the Data Abstract service as owner.
constructor(owner: DataAbstractService; session: ISession)
ScriptContext(DataAbstractService owner, ISession session)
Sub New(owner As DataAbstractService, session As ISession)
Parameters:
- owner: Service instance that is considered to be the owner of the new script context
- session: Current session of the new script context
AddRole
Adds the specified role name to the roles array of the current session.
Implementation of the IScriptSession interface.
method AddRole(role: String)
void AddRole(String role)
Sub AddRole(role As String)
Parameters:
- role: Role name to add
ApplyChanges
Stub for the implementation of the IServerScriptContext interface.
Parameters:
- delta:
ChangeSession
Replaces the current session with an input one.
method ChangeSession(session: ISession)
void ChangeSession(ISession session)
Sub ChangeSession(session As ISession)
Parameters:
- session: New session
CreateCommandAdapter
method CreateCommandAdapter: BaseCommand
BaseCommand CreateCommandAdapter()
Function CreateCommandAdapter() As BaseCommand
CreateDataAdapter
method CreateDataAdapter: DataAdapter
DataAdapter CreateDataAdapter()
Function CreateDataAdapter() As DataAdapter
Fetch (String, array of DataParameter): IDataReader
Stub for the implementation of the IServerScriptContext interface.
method Fetch(sql: String; parameters: array of DataParameter): IDataReader
IDataReader Fetch(String sql, DataParameter[] parameters)
Function Fetch(sql As String, parameters As DataParameter()) As IDataReader
Parameters:
- sql:
- parameters:
Fetch (String, array of String, String, array of DataParameter): IDataReader
Stub for the implementation of the IServerScriptContext interface.
method Fetch(tableName: String; fields: array of String; whereClause: String; parameters: array of DataParameter): IDataReader
IDataReader Fetch(String tableName, String[] fields, String whereClause, DataParameter[] parameters)
Function Fetch(tableName As String, fields As String(), whereClause As String, parameters As DataParameter()) As IDataReader
Parameters:
- tableName:
- fields:
- whereClause:
- parameters:
GetConnectionName
Gets the connection name from the ConnectionManager.ConnectionDefinitions item at the specified index.
Implementation of the IServerScriptContext interface.
method GetConnectionName(index: Int32): String
String GetConnectionName(Int32 index)
Function GetConnectionName(index As Int32) As String
Parameters:
- index: Index of the ConnectionDefinition whose name is required
GetConnectionString
Gets the connection string from the ConnectionManager.ConnectionDefinitions item at the specified index.
Implementation of the IServerScriptContext interface.
method GetConnectionString(index: Int32): String
String GetConnectionString(Int32 index)
Function GetConnectionString(index As Int32) As String
Parameters:
- index: Index of the ConnectionDefinition whose connection string is required
GetConnectionType
Gets the connection type from the ConnectionManager.ConnectionDefinitions item at the specified index.
Implementation of the IServerScriptContext interface.
method GetConnectionType(index: Int32): String
String GetConnectionType(Int32 index)
Function GetConnectionType(index As Int32) As String
Parameters:
- index: Index of the ConnectionDefinition whose connection type is required
HasRole
Determines whether the current session contains the role with the specified name.
Implementation of the IScriptSession interface.
method HasRole(role: String): Boolean
Boolean HasRole(String role)
Function HasRole(role As String) As Boolean
Parameters:
- role: Role key to be located in the session
RemoveRole
Removes the role with the specified name from the current session.
Implementation of the IScriptSession interface.
method RemoveRole(role: String)
void RemoveRole(String role)
Sub RemoveRole(role As String)
Parameters:
- role: Role name to remove