DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | Package Functions | Properties | Private Member Functions | Private Attributes | List of all members
Deveel.Data.Routines.InvokeContext Class Reference

Encapsulates the More...

Inheritance diagram for Deveel.Data.Routines.InvokeContext:

Public Member Functions

bool TryGetArgument (string argName, out SqlExpression value)
 
bool TryGetArgument (string argName, out DataObject value)
 
bool HasArgument (string argName)
 
InvokeResult Result (DataObject value)
 
InvokeResult Result ()
 
void SetOutput (string argName, DataObject value)
 
void Dispose ()
 

Package Functions

 InvokeContext (Invoke invoke, IRoutine routine, IVariableResolver resolver, IGroupResolver group, IRequest request)
 

Properties

Invoke Invoke [get, private set]
 Gets the information about the invoke of the routine. More...
 
IRoutine Routine [get, private set]
 Gets the instance of the IRoutine being executed. More...
 
RoutineType RoutineType [get]
 Gets the type of the routine being executed. More...
 
SqlExpression[] Arguments [get]
 Gets the array of expressions forming the arguments of the execution. More...
 
IVariableResolver VariableResolver [get, private set]
 
IGroupResolver GroupResolver [get, private set]
 
IRequest Request [get, private set]
 
DataObject[] EvaluatedArguments [get]
 
int ArgumentCount [get]
 Gets a count of the arguments passed to the routine. More...
 

Private Member Functions

 ~InvokeContext ()
 
RoutineParameter GetParameter (string name)
 
void Dispose (bool disposing)
 

Private Attributes

DataObject[] evaluatedArgs
 
Dictionary< string, DataObjectoutput
 

Detailed Description

Encapsulates the

Definition at line 28 of file InvokeContext.cs.

Constructor & Destructor Documentation

Deveel.Data.Routines.InvokeContext.InvokeContext ( Invoke  invoke,
IRoutine  routine,
IVariableResolver  resolver,
IGroupResolver  group,
IRequest  request 
)
inlinepackage

Definition at line 32 of file InvokeContext.cs.

32  {
33  if (invoke == null)
34  throw new ArgumentNullException("invoke");
35  if (routine == null)
36  throw new ArgumentNullException("routine");
37 
38  Request = request;
39  GroupResolver = group;
40  VariableResolver = resolver;
41  Invoke = invoke;
42  Routine = routine;
43  }
Invoke Invoke
Gets the information about the invoke of the routine.
IRoutine Routine
Gets the instance of the IRoutine being executed.
Deveel.Data.Routines.InvokeContext.~InvokeContext ( )
inlineprivate

Definition at line 45 of file InvokeContext.cs.

45  {
46  Dispose(false);
47  }

Member Function Documentation

void Deveel.Data.Routines.InvokeContext.Dispose ( bool  disposing)
inlineprivate

Definition at line 182 of file InvokeContext.cs.

182  {
183  Routine = null;
184  Invoke = null;
185  evaluatedArgs = null;
186  output = null;
187  }
Invoke Invoke
Gets the information about the invoke of the routine.
IRoutine Routine
Gets the instance of the IRoutine being executed.
Dictionary< string, DataObject > output
void Deveel.Data.Routines.InvokeContext.Dispose ( )
inline

Definition at line 189 of file InvokeContext.cs.

189  {
190  Dispose(true);
191  GC.SuppressFinalize(this);
192  }
RoutineParameter Deveel.Data.Routines.InvokeContext.GetParameter ( string  name)
inlineprivate

Definition at line 155 of file InvokeContext.cs.

155  {
156  return Routine.RoutineInfo.Parameters.FirstOrDefault(x => x.Name.Equals(name, StringComparison.Ordinal));
157  }
RoutineParameter[] Parameters
Gets an array of parameters for the routine.
Definition: RoutineInfo.cs:72
IRoutine Routine
Gets the instance of the IRoutine being executed.
bool Deveel.Data.Routines.InvokeContext.HasArgument ( string  argName)
inline

Definition at line 137 of file InvokeContext.cs.

137  {
138  throw new NotImplementedException();
139  }
InvokeResult Deveel.Data.Routines.InvokeContext.Result ( DataObject  value)
inline

Definition at line 141 of file InvokeContext.cs.

141  {
142  if (Routine.Type != RoutineType.Function)
143  throw new InvalidOperationException("The routine is not a function.");
144 
145  return new InvokeResult(this, value);
146  }
RoutineType RoutineType
Gets the type of the routine being executed.
IRoutine Routine
Gets the instance of the IRoutine being executed.
RoutineType Type
Gets the type of routine that will be executed.
Definition: IRoutine.cs:31
InvokeResult Deveel.Data.Routines.InvokeContext.Result ( )
inline

Definition at line 148 of file InvokeContext.cs.

148  {
149  if (Routine.Type != RoutineType.Procedure)
150  throw new InvalidOperationException("The routine is not a procedure: a return value is required.");
151 
152  return new InvokeResult(this);
153  }
RoutineType RoutineType
Gets the type of the routine being executed.
IRoutine Routine
Gets the instance of the IRoutine being executed.
RoutineType Type
Gets the type of routine that will be executed.
Definition: IRoutine.cs:31
void Deveel.Data.Routines.InvokeContext.SetOutput ( string  argName,
DataObject  value 
)
inline

Definition at line 159 of file InvokeContext.cs.

159  {
160  var parameter = GetParameter(argName);
161  if (parameter == null)
162  throw new InvalidOperationException(String.Format("Routine {0} has none parameter named '{1}'.", Routine.FullName, argName));
163  if (!parameter.IsOutput)
164  throw new InvalidOperationException();
165 
166  if (!parameter.IsNullable &&
167  value.IsNull)
168  throw new ArgumentException();
169 
170  if (!parameter.IsUnbounded)
171  throw new ArgumentException();
172 
173  if (!parameter.Type.IsComparable(value.Type))
174  throw new ArgumentException();
175 
176  if (output == null)
177  output = new Dictionary<string, DataObject>();
178 
179  output[argName] = value;
180  }
A long string in the system.
ObjectName FullName
Gets the fully qualified name of the object used to resolve it uniquely within the database...
Definition: IDbObject.cs:30
RoutineParameter GetParameter(string name)
IRoutine Routine
Gets the instance of the IRoutine being executed.
Dictionary< string, DataObject > output
bool Deveel.Data.Routines.InvokeContext.TryGetArgument ( string  argName,
out SqlExpression  value 
)
inline

Definition at line 107 of file InvokeContext.cs.

107  {
108  var parameter = Routine.RoutineInfo.Parameters.FirstOrDefault(x => x.Name.Equals(argName, StringComparison.Ordinal));
109  if (parameter == null) {
110  value = null;
111  return false;
112  }
113 
114  var offset = parameter.Offset;
115  if (parameter.IsUnbounded) {
116  // TODO: Copy all arguments starting at the given offset and make an Array
117  var tuple = SqlExpression.Tuple(new SqlExpression[0]);
118  value = tuple;
119  } else {
120  value = Invoke.Arguments[offset];
121  }
122 
123  return true;
124  }
SqlExpression[] Arguments
Gets an array of arguments to be passed to the invoked routine.
Definition: Invoke.cs:63
static SqlTupleExpression Tuple(SqlExpression[] expressions)
Invoke Invoke
Gets the information about the invoke of the routine.
RoutineParameter[] Parameters
Gets an array of parameters for the routine.
Definition: RoutineInfo.cs:72
IRoutine Routine
Gets the instance of the IRoutine being executed.
Defines the base class for instances that represent SQL expression tree nodes.
bool Deveel.Data.Routines.InvokeContext.TryGetArgument ( string  argName,
out DataObject  value 
)
inline

Definition at line 126 of file InvokeContext.cs.

126  {
127  SqlExpression exp;
128  if (!TryGetArgument(argName, out exp)) {
129  value = DataObject.Null();
130  return false;
131  }
132 
133  value = exp.EvaluateToConstant(Request, VariableResolver);
134  return true;
135  }
bool TryGetArgument(string argName, out SqlExpression value)
Defines the base class for instances that represent SQL expression tree nodes.

Member Data Documentation

DataObject [] Deveel.Data.Routines.InvokeContext.evaluatedArgs
private

Definition at line 29 of file InvokeContext.cs.

Dictionary<string, DataObject> Deveel.Data.Routines.InvokeContext.output
private

Definition at line 30 of file InvokeContext.cs.

Property Documentation

int Deveel.Data.Routines.InvokeContext.ArgumentCount
get

Gets a count of the arguments passed to the routine.

See also
Arguments

Definition at line 103 of file InvokeContext.cs.

SqlExpression [] Deveel.Data.Routines.InvokeContext.Arguments
get

Gets the array of expressions forming the arguments of the execution.

See also
SqlExpression, Routines.Invoke.Arguments, Invoke

Definition at line 76 of file InvokeContext.cs.

DataObject [] Deveel.Data.Routines.InvokeContext.EvaluatedArguments
get

Definition at line 86 of file InvokeContext.cs.

IGroupResolver Deveel.Data.Routines.InvokeContext.GroupResolver
getprivate set

Definition at line 82 of file InvokeContext.cs.

Invoke Deveel.Data.Routines.InvokeContext.Invoke
getprivate set

Gets the information about the invoke of the routine.

See also
Routines.Invoke

Definition at line 53 of file InvokeContext.cs.

IRequest Deveel.Data.Routines.InvokeContext.Request
getprivate set

Definition at line 84 of file InvokeContext.cs.

IRoutine Deveel.Data.Routines.InvokeContext.Routine
getprivate set

Gets the instance of the IRoutine being executed.

See also
IRoutine

Definition at line 59 of file InvokeContext.cs.

RoutineType Deveel.Data.Routines.InvokeContext.RoutineType
get

Gets the type of the routine being executed.

See also
RoutineType, IRoutine.Type

Definition at line 66 of file InvokeContext.cs.

IVariableResolver Deveel.Data.Routines.InvokeContext.VariableResolver
getprivate set

Definition at line 80 of file InvokeContext.cs.


The documentation for this class was generated from the following file: