DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
CursorParameter.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.IO;
19 
20 using Deveel.Data.Types;
21 
22 namespace Deveel.Data.Sql.Cursors {
23  public sealed class CursorParameter {
24  public CursorParameter(string parameterName, SqlType parameterType) {
25  if (String.IsNullOrEmpty(parameterName))
26  throw new ArgumentNullException("parameterName");
27  if (parameterType == null)
28  throw new ArgumentNullException("parameterType");
29 
30  ParameterName = parameterName;
31  ParameterType = parameterType;
32  }
33 
34  public string ParameterName { get; private set; }
35 
36  public SqlType ParameterType { get; private set; }
37 
38  public int Offset { get; set; }
39 
40  public static void Serialize(CursorParameter parameter, BinaryWriter writer) {
41  writer.Write(parameter.ParameterName);
42  TypeSerializer.SerializeTo(writer, parameter.ParameterType);
43  writer.Write(parameter.Offset);
44  }
45 
46  public static CursorParameter Deserialize(BinaryReader reader) {
47  var paramName = reader.ReadString();
48  // TODO: Type Resolver!!!
49  var paramType = TypeSerializer.Deserialize(reader, null);
50  var offset = reader.ReadInt32();
51 
52  return new CursorParameter(paramName, paramType) {
53  Offset = offset
54  };
55  }
56  }
57 }
static void SerializeTo(BinaryWriter writer, SqlType type)
A long string in the system.
static void Serialize(CursorParameter parameter, BinaryWriter writer)
static SqlType Deserialize(BinaryReader reader, ITypeResolver resolver)
static CursorParameter Deserialize(BinaryReader reader)
Defines the properties of a specific SQL Type and handles the values compatible.
Definition: SqlType.cs:33
CursorParameter(string parameterName, SqlType parameterType)