DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
InvokeResult.cs
Go to the documentation of this file.
1 //
2 // Copyright 2010-2015 Deveel
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 using System;
18 using System.Collections.Generic;
19 using System.Linq;
20 
21 namespace Deveel.Data.Routines {
25  public sealed class InvokeResult {
26  private Dictionary<string, DataObject> outputValues;
27 
28  private InvokeResult(InvokeContext context, DataObject returnValue, bool hasReturn) {
29  Context = context;
30  ReturnValue = returnValue;
31  HasReturnValue = hasReturn;
32  }
33 
34  internal InvokeResult(InvokeContext context)
35  : this(context, DataObject.Null(), false) {
36  }
37 
38  internal InvokeResult(InvokeContext context, DataObject returnValue)
39  : this(context, returnValue, true) {
40  }
41 
45  public InvokeContext Context { get; private set; }
46 
59  public DataObject ReturnValue { get; private set; }
60 
69  public bool HasReturnValue { get; private set; }
70 
76  public bool HasOutputParameters {
77  get { return outputValues != null && outputValues.Count > 0; }
78  }
79 
83  public IDictionary<string, DataObject> OutputParameters {
84  get {
85  if (outputValues == null)
86  return new Dictionary<string, DataObject>();
87 
88  return outputValues.ToDictionary(x => x.Key, y => y.Value);
89  }
90  }
91 
92  internal void SetOutputParameter(string name, DataObject value) {
93  if (Context.RoutineType != RoutineType.Procedure)
94  throw new Exception("Cannot set an output parameter value for a function.");
95 
96  if (outputValues == null)
97  outputValues = new Dictionary<string, DataObject>();
98 
99  outputValues[name] = value;
100  }
101  }
102 }
InvokeResult(InvokeContext context, DataObject returnValue)
Definition: InvokeResult.cs:38
void SetOutputParameter(string name, DataObject value)
Definition: InvokeResult.cs:92
InvokeResult(InvokeContext context)
Definition: InvokeResult.cs:34
InvokeResult(InvokeContext context, DataObject returnValue, bool hasReturn)
Definition: InvokeResult.cs:28
RoutineType
The type of routine program.
Definition: RoutineType.cs:23
Dictionary< string, DataObject > outputValues
Definition: InvokeResult.cs:26
Represents the result of the execution of a routine.
Definition: InvokeResult.cs:25
Represents a dynamic object that encapsulates a defined SqlType and a compatible constant ISqlObject ...
Definition: DataObject.cs:35