DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Classes | Static Public Member Functions | List of all members
Deveel.Data.Sql.Variables.ContextExtensions Class Reference

Classes

class  ContextVariableResolver
 

Static Public Member Functions

static Variable FindVariable (this IContext context, string variableName)
 
static bool VariableExists (this IContext context, string variableName)
 
static bool DropVariable (this IContext context, string variableName)
 
static Variable DeclareVariable (this IContext context, VariableInfo variableInfo)
 
static Variable DeclareVariable (this IContext context, string variableName, SqlType variableType)
 
static Variable DeclareVariable (this IContext context, string variableName, SqlType variableType, bool constant)
 
static Variable SetVariable (this IContext context, string variableName, SqlExpression value)
 
static IVariableResolver VariableResolver (this IContext context)
 

Detailed Description

Definition at line 24 of file ContextExtensions.cs.

Member Function Documentation

static Variable Deveel.Data.Sql.Variables.ContextExtensions.DeclareVariable ( this IContext  context,
VariableInfo  variableInfo 
)
inlinestatic

Definition at line 77 of file ContextExtensions.cs.

77  {
78  if (context.VariableExists(variableInfo.VariableName))
79  throw new InvalidOperationException(String.Format("Variable '{0}' already defined in the context hierarchy.", variableInfo.VariableName));
80 
81  var currentContext = context;
82  while (currentContext != null) {
83  if (currentContext is IVariableScope) {
84  var scope = (IVariableScope)currentContext;
85  return scope.DefineVariable(variableInfo);
86  }
87 
88  currentContext = currentContext.Parent;
89  }
90 
91  // not found in the hierarchy
92  return null;
93  }
A long string in the system.
static Variable Deveel.Data.Sql.Variables.ContextExtensions.DeclareVariable ( this IContext  context,
string  variableName,
SqlType  variableType 
)
inlinestatic

Definition at line 95 of file ContextExtensions.cs.

95  {
96  return DeclareVariable(context, variableName, variableType, false);
97  }
static Variable DeclareVariable(this IContext context, VariableInfo variableInfo)
static Variable Deveel.Data.Sql.Variables.ContextExtensions.DeclareVariable ( this IContext  context,
string  variableName,
SqlType  variableType,
bool  constant 
)
inlinestatic

Definition at line 99 of file ContextExtensions.cs.

99  {
100  return context.DeclareVariable(new VariableInfo(variableName, variableType, constant));
101  }
static bool Deveel.Data.Sql.Variables.ContextExtensions.DropVariable ( this IContext  context,
string  variableName 
)
inlinestatic

Definition at line 60 of file ContextExtensions.cs.

60  {
61  var currentContext = context;
62  while (currentContext != null) {
63  if (currentContext is IVariableScope) {
64  var scope = (IVariableScope)currentContext;
65  if (scope.HasVariable(variableName))
66  return scope.DropVariable(variableName);
67  }
68 
69  currentContext = currentContext.Parent;
70  }
71 
72 
73  // not found in the hierarchy
74  return false;
75  }
static Variable Deveel.Data.Sql.Variables.ContextExtensions.FindVariable ( this IContext  context,
string  variableName 
)
inlinestatic

Definition at line 25 of file ContextExtensions.cs.

25  {
26  var currentContext = context;
27  while (currentContext != null) {
28  if (currentContext is IVariableScope) {
29  var scope = (IVariableScope) currentContext;
30  var variable = scope.GetVariable(variableName);
31  if (variable != null)
32  return variable;
33  }
34 
35  currentContext = currentContext.Parent;
36  }
37 
38 
39  // not found in the hierarchy
40  return null;
41  }
static Variable Deveel.Data.Sql.Variables.ContextExtensions.SetVariable ( this IContext  context,
string  variableName,
SqlExpression  value 
)
inlinestatic

Definition at line 103 of file ContextExtensions.cs.

103  {
104  var currentContext = context;
105  while (currentContext != null) {
106  if (currentContext is IVariableScope) {
107  var scope = (IVariableScope) currentContext;
108  if (scope.HasVariable(variableName)) {
109  // TODO: support also in-context evaluation
110  var constantValue = value.EvaluateToConstant(null, context.VariableResolver());
111  return scope.SetVariable(variableName, constantValue);
112  }
113  }
114 
115  currentContext = currentContext.Parent;
116  }
117 
118  currentContext = context;
119  while (currentContext != null) {
120  if (currentContext is IVariableScope) {
121  var scope = (IVariableScope)currentContext;
122  // TODO: support also in-context evaluation
123  var constantValue = value.EvaluateToConstant(null, context.VariableResolver());
124  return scope.SetVariable(variableName, constantValue);
125  }
126 
127  currentContext = currentContext.Parent;
128  }
129 
130  // not found in the hierarchy
131  return null;
132  }
static bool Deveel.Data.Sql.Variables.ContextExtensions.VariableExists ( this IContext  context,
string  variableName 
)
inlinestatic

Definition at line 43 of file ContextExtensions.cs.

43  {
44  var currentContext = context;
45  while (currentContext != null) {
46  if (currentContext is IVariableScope) {
47  var scope = (IVariableScope)currentContext;
48  if (scope.HasVariable(variableName))
49  return true;
50  }
51 
52  currentContext = currentContext.Parent;
53  }
54 
55 
56  // not found in the hierarchy
57  return false;
58  }
static IVariableResolver Deveel.Data.Sql.Variables.ContextExtensions.VariableResolver ( this IContext  context)
inlinestatic

Definition at line 134 of file ContextExtensions.cs.

134  {
135  return new ContextVariableResolver(context);
136  }

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