DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Classes | Public Member Functions | Protected Member Functions | Properties | Private Member Functions | Private Attributes | List of all members
Deveel.Data.Routines.FunctionProvider Class Referenceabstract
Inheritance diagram for Deveel.Data.Routines.FunctionProvider:
Deveel.Data.Routines.IRoutineResolver Deveel.Data.Sql.Fluid.IConfigurationContext Deveel.Data.Routines.FunctionBuildTests.Factory1 Deveel.Data.Routines.FunctionBuildTests.Factory2 Deveel.Data.Routines.SystemFunctionsProvider Deveel.Data.Spatial.SpatialFunctionProvider Deveel.Data.Xml.XmlFunctionProvider

Classes

class  DelegateFunction
 
class  FunctionConfiguration
 
class  FunctionParameterConfiguration
 

Public Member Functions

IFunction ResolveFunction (Invoke invoke, IQuery query)
 
void Dispose ()
 

Protected Member Functions

 FunctionProvider ()
 
abstract void OnInit ()
 
virtual ObjectName NormalizeName (ObjectName name)
 
void Register (FunctionInfo functionInfo, Func< InvokeContext, InvokeResult > body, Func< InvokeContext, SqlType > returnType)
 
void Register (Func< IFunctionConfiguration, IFunctionConfiguration > config)
 
void Register (IFunction function)
 
virtual void Dispose (bool disposing)
 

Properties

abstract string SchemaName [get]
 
- Properties inherited from Deveel.Data.Sql.Fluid.IConfigurationContext
string SchemaName [get]
 

Private Member Functions

 ~FunctionProvider ()
 
void CallInit ()
 
IRoutine IRoutineResolver. ResolveRoutine (Invoke request, IQuery query)
 Resolves a routine that matches the given invocation within the context provided. More...
 

Private Attributes

Container container
 

Detailed Description

Definition at line 29 of file FunctionProvider.cs.

Constructor & Destructor Documentation

Deveel.Data.Routines.FunctionProvider.FunctionProvider ( )
inlineprotected

Definition at line 32 of file FunctionProvider.cs.

32  {
33  container = new Container(Rules.Default.WithResolveIEnumerableAsLazyEnumerable());
34  CallInit();
35  }
Deveel.Data.Routines.FunctionProvider.~FunctionProvider ( )
inlineprivate

Definition at line 37 of file FunctionProvider.cs.

37  {
38  Dispose(false);
39  }

Member Function Documentation

void Deveel.Data.Routines.FunctionProvider.CallInit ( )
inlineprivate

Definition at line 43 of file FunctionProvider.cs.

43  {
44  OnInit();
45  }
void Deveel.Data.Routines.FunctionProvider.Dispose ( )
inline

Definition at line 298 of file FunctionProvider.cs.

298  {
299  Dispose(true);
300  GC.SuppressFinalize(this);
301  }
virtual void Deveel.Data.Routines.FunctionProvider.Dispose ( bool  disposing)
inlineprotectedvirtual

Definition at line 303 of file FunctionProvider.cs.

303  {
304  if (disposing) {
305  if (container != null)
306  container.Dispose();
307  }
308 
309  container = null;
310  }
virtual ObjectName Deveel.Data.Routines.FunctionProvider.NormalizeName ( ObjectName  name)
inlineprotectedvirtual

Reimplemented in Deveel.Data.Routines.SystemFunctionsProvider, Deveel.Data.Spatial.SpatialFunctionProvider, and Deveel.Data.Xml.XmlFunctionProvider.

Definition at line 49 of file FunctionProvider.cs.

49  {
50  var parentName = name.Parent;
51  if (parentName == null)
52  return null;
53 
54  return name;
55  }
ObjectName Parent
Gets the parent reference of the current one, if any or null if none.
Definition: ObjectName.cs:99
abstract void Deveel.Data.Routines.FunctionProvider.OnInit ( )
protectedpure virtual
void Deveel.Data.Routines.FunctionProvider.Register ( FunctionInfo  functionInfo,
Func< InvokeContext, InvokeResult body,
Func< InvokeContext, SqlType returnType 
)
inlineprotected

Definition at line 57 of file FunctionProvider.cs.

57  {
58  Register(new DelegateFunction(functionInfo, body, returnType));
59  }
void Register(FunctionInfo functionInfo, Func< InvokeContext, InvokeResult > body, Func< InvokeContext, SqlType > returnType)
void Deveel.Data.Routines.FunctionProvider.Register ( Func< IFunctionConfiguration, IFunctionConfiguration config)
inlineprotected

Definition at line 61 of file FunctionProvider.cs.

61  {
62  if (config == null)
63  return;
64 
65  var configuration = new FunctionConfiguration(this);
66  config(configuration);
67 
68  var functionInfos = configuration.FunctionInfo;
69  foreach (var functionInfo in functionInfos) {
70  Register(functionInfo, configuration.ExecuteFunc, configuration.ReturnTypeFunc);
71  }
72  }
void Register(FunctionInfo functionInfo, Func< InvokeContext, InvokeResult > body, Func< InvokeContext, SqlType > returnType)
void Deveel.Data.Routines.FunctionProvider.Register ( IFunction  function)
inlineprotected

Definition at line 74 of file FunctionProvider.cs.

74  {
75  if (function == null)
76  throw new ArgumentNullException("function");
77 
78  var functionName = function.FullName.FullName.ToUpperInvariant();
79  container.RegisterInstance(function, serviceKey: functionName,reuse:Reuse.Singleton);
80  }
IFunction Deveel.Data.Routines.FunctionProvider.ResolveFunction ( Invoke  invoke,
IQuery  query 
)
inline

Definition at line 86 of file FunctionProvider.cs.

86  {
87  var name = NormalizeName(invoke.RoutineName);
88 
89  if (name == null ||
90  !name.ParentName.Equals(SchemaName))
91  return null;
92 
93  var functionName = name.FullName.ToUpperInvariant();
94  var functions = container.ResolveMany<IFunction>(serviceKey:functionName).ToArrayOrSelf();
95  if (functions.Length == 0)
96  return null;
97  if (functions.Length == 1)
98  return functions[0];
99 
100  return functions.FirstOrDefault(x => x.RoutineInfo.MatchesInvoke(invoke, query));
101  }
virtual ObjectName NormalizeName(ObjectName name)
IRoutine IRoutineResolver. Deveel.Data.Routines.FunctionProvider.ResolveRoutine ( Invoke  request,
IQuery  query 
)
inlineprivate

Resolves a routine that matches the given invocation within the context provided.

Parameters
requestThe routine invocation request used to resolve the routine.
queryThe parent query context.
Returns
Returns an instance of IRoutine that matches the given request, or null if no routine was found in the underlying context.

Implements Deveel.Data.Routines.IRoutineResolver.

Definition at line 82 of file FunctionProvider.cs.

82  {
83  return ResolveFunction(request, query);
84  }
IFunction ResolveFunction(Invoke invoke, IQuery query)

Member Data Documentation

Container Deveel.Data.Routines.FunctionProvider.container
private

Definition at line 30 of file FunctionProvider.cs.

Property Documentation

abstract string Deveel.Data.Routines.FunctionProvider.SchemaName
get

Definition at line 41 of file FunctionProvider.cs.


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