DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Deveel.Data.Routines.ExternalFunction Class Reference
Inheritance diagram for Deveel.Data.Routines.ExternalFunction:
Deveel.Data.Routines.Function Deveel.Data.Routines.IFunction Deveel.Data.Routines.IRoutine Deveel.Data.Sql.IDbObject

Public Member Functions

 ExternalFunction (FunctionInfo functionInfo)
 
override InvokeResult Execute (InvokeContext context)
 Executes the function and provides a result. More...
 
override SqlType ReturnType (InvokeContext context)
 Resolves the function return type against the given context. More...
 
- Public Member Functions inherited from Deveel.Data.Routines.Function
SqlType ReturnType ()
 Gets the function static return type More...
 

Private Member Functions

DataObject ConvertValue (object value, SqlType sqlType)
 
object[] ConvertArguments (MethodInfo methodInfo, DataObject[] args)
 
MethodInfo DiscoverMethod ()
 

Private Attributes

MethodInfo method
 

Additional Inherited Members

- Static Public Attributes inherited from Deveel.Data.Routines.Function
static readonly SqlType DynamicType = new DynamicSqlType()
 A special SqlType that is used to mark an argument of a function as dynamic. More...
 
- Protected Member Functions inherited from Deveel.Data.Routines.Function
 Function (FunctionInfo functionInfo)
 
 Function (ObjectName name, RoutineParameter[] parameters, FunctionType functionType)
 
 Function (ObjectName name, RoutineParameter[] parameters, SqlType returnType)
 
 Function (ObjectName name, RoutineParameter[] parameters, SqlType returnType, FunctionType functionType)
 
- Properties inherited from Deveel.Data.Routines.Function
FunctionType FunctionType [get]
 
FunctionInfo FunctionInfo [get, private set]
 
ObjectName FunctionName [get]
 
RoutineInfo IRoutine. RoutineInfo [get]
 
RoutineType IRoutine. Type [get]
 
DbObjectType IDbObject. ObjectType [get]
 
ObjectName IDbObject. FullName [get]
 
- Properties inherited from Deveel.Data.Routines.IFunction
FunctionType FunctionType [get]
 Gets the type of function. More...
 
- Properties inherited from Deveel.Data.Routines.IRoutine
RoutineType Type [get]
 Gets the type of routine that will be executed. More...
 
RoutineInfo RoutineInfo [get]
 
- Properties inherited from Deveel.Data.Sql.IDbObject
ObjectName FullName [get]
 Gets the fully qualified name of the object used to resolve it uniquely within the database. More...
 
DbObjectType ObjectType [get]
 Gets the type of database object that the implementation is for More...
 

Detailed Description

Definition at line 23 of file ExternalFunction.cs.

Constructor & Destructor Documentation

Deveel.Data.Routines.ExternalFunction.ExternalFunction ( FunctionInfo  functionInfo)
inline

Definition at line 26 of file ExternalFunction.cs.

27  : base(functionInfo) {
28  if (functionInfo.FunctionType != FunctionType.External)
29  throw new ArgumentException("The information specified are not pointing to any external function.");
30  }

Member Function Documentation

object [] Deveel.Data.Routines.ExternalFunction.ConvertArguments ( MethodInfo  methodInfo,
DataObject[]  args 
)
inlineprivate

Definition at line 55 of file ExternalFunction.cs.

55  {
56  var methodParams = methodInfo.GetParameters();
57 
58  if (methodParams.Length != args.Length)
59  throw new InvalidOperationException(); // TODO: support the case of the Unbounded parameters
60 
61  var values = new object[args.Length];
62  for (int i = 0; i < args.Length; i++) {
63  var paramType = methodParams[i].ParameterType;
64  var sqlType = PrimitiveTypes.FromType(paramType);
65 
66  values[i] = sqlType.ConvertTo(args[i].Value, paramType);
67  }
68 
69  return values;
70  }
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
virtual object ConvertTo(ISqlObject obj, Type destType)
Definition: SqlType.cs:188
static SqlType FromType(Type type)
DataObject Deveel.Data.Routines.ExternalFunction.ConvertValue ( object  value,
SqlType  sqlType 
)
inlineprivate

Definition at line 51 of file ExternalFunction.cs.

51  {
52  throw new NotImplementedException();
53  }
MethodInfo Deveel.Data.Routines.ExternalFunction.DiscoverMethod ( )
inlineprivate

Definition at line 79 of file ExternalFunction.cs.

79  {
80  var type = FunctionInfo.ExternalType;
81  var methodName = FunctionInfo.ExternalMethodName;
82  if (String.IsNullOrEmpty(methodName))
83  methodName = FunctionInfo.RoutineName.Name;
84 
85  throw new NotImplementedException();
86  }
A long string in the system.
ObjectName RoutineName
Gets the name of the routine that uniquely identifies it in a system context.
Definition: RoutineInfo.cs:65
override InvokeResult Deveel.Data.Routines.ExternalFunction.Execute ( InvokeContext  context)
inlinevirtual

Executes the function and provides a result.

Parameters
contextThe context of the execution.
Returns
Returns a InvokeResult instance that encapsulates the returned value of the function.
See also
InvokeResult.ReturnValue

Implements Deveel.Data.Routines.Function.

Definition at line 32 of file ExternalFunction.cs.

32  {
33  if (method == null)
35 
36  if (method == null)
37  throw new InvalidOperationException();
38 
39  var args = context.EvaluatedArguments;
40 
41  try {
42  var methodArgs = ConvertArguments(method, args);
43  var result = method.Invoke(null, methodArgs);
44 
45  return context.Result(ConvertValue(result, ReturnType()));
46  } catch (Exception) {
47  throw;
48  }
49  }
DataObject ConvertValue(object value, SqlType sqlType)
object[] ConvertArguments(MethodInfo methodInfo, DataObject[] args)
SqlType ReturnType()
Gets the function static return type
Definition: Function.cs:104
override SqlType Deveel.Data.Routines.ExternalFunction.ReturnType ( InvokeContext  context)
inlinevirtual

Resolves the function return type against the given context.

Parameters
contextThe execution context used to resolve the function return type.
Returns
Returns an instance of SqlType that defines the type of the returned value resolved against the given execution context..

Reimplemented from Deveel.Data.Routines.Function.

Definition at line 72 of file ExternalFunction.cs.

72  {
73  if (method == null)
75 
76  return base.ReturnType(context);
77  }

Member Data Documentation

MethodInfo Deveel.Data.Routines.ExternalFunction.method
private

Definition at line 24 of file ExternalFunction.cs.


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