aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ThirdParty/TribalMedia/TribalMedia.Framework.Data/DataReader.cs
diff options
context:
space:
mode:
authorJeff Ames2008-01-14 16:47:36 +0000
committerJeff Ames2008-01-14 16:47:36 +0000
commit6716668187675d5950d2b3a7a925da7327440ca1 (patch)
treea1448cee1cf162b0d5c0e755fae5b956f465ec51 /ThirdParty/TribalMedia/TribalMedia.Framework.Data/DataReader.cs
parentRemove unused SOG constructor (diff)
downloadopensim-SC_OLD-6716668187675d5950d2b3a7a925da7327440ca1.zip
opensim-SC_OLD-6716668187675d5950d2b3a7a925da7327440ca1.tar.gz
opensim-SC_OLD-6716668187675d5950d2b3a7a925da7327440ca1.tar.bz2
opensim-SC_OLD-6716668187675d5950d2b3a7a925da7327440ca1.tar.xz
Set svn:eol-style.
Diffstat (limited to 'ThirdParty/TribalMedia/TribalMedia.Framework.Data/DataReader.cs')
-rw-r--r--ThirdParty/TribalMedia/TribalMedia.Framework.Data/DataReader.cs298
1 files changed, 149 insertions, 149 deletions
diff --git a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/DataReader.cs b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/DataReader.cs
index f0b3e88..6f84d43 100644
--- a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/DataReader.cs
+++ b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/DataReader.cs
@@ -1,150 +1,150 @@
1/* 1/*
2* Copyright (c) Tribal Media AB, http://tribalmedia.se/ 2* Copyright (c) Tribal Media AB, http://tribalmedia.se/
3* 3*
4* Redistribution and use in source and binary forms, with or without 4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met: 5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright 6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer. 7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright 8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the 9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution. 10* documentation and/or other materials provided with the distribution.
11* * The name of Tribal Media AB may not be used to endorse or promote products 11* * The name of Tribal Media AB may not be used to endorse or promote products
12* derived from this software without specific prior written permission. 12* derived from this software without specific prior written permission.
13* 13*
14* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 14* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
15* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 17* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
18* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24* 24*
25*/ 25*/
26 26
27using System; 27using System;
28using System.Data; 28using System.Data;
29using System.IO; 29using System.IO;
30 30
31namespace TribalMedia.Framework.Data 31namespace TribalMedia.Framework.Data
32{ 32{
33 public class DataReader 33 public class DataReader
34 { 34 {
35 private readonly IDataReader m_source; 35 private readonly IDataReader m_source;
36 36
37 public DataReader(IDataReader source) 37 public DataReader(IDataReader source)
38 { 38 {
39 m_source = source; 39 m_source = source;
40 } 40 }
41 41
42 public object Get(string name) 42 public object Get(string name)
43 { 43 {
44 return m_source[name]; 44 return m_source[name];
45 } 45 }
46 46
47 public ushort GetUShort(string name) 47 public ushort GetUShort(string name)
48 { 48 {
49 return (ushort) m_source.GetInt32(m_source.GetOrdinal(name)); 49 return (ushort) m_source.GetInt32(m_source.GetOrdinal(name));
50 } 50 }
51 51
52 public byte GetByte(string name) 52 public byte GetByte(string name)
53 { 53 {
54 int ordinal = m_source.GetOrdinal(name); 54 int ordinal = m_source.GetOrdinal(name);
55 byte value = (byte) m_source.GetInt16(ordinal); 55 byte value = (byte) m_source.GetInt16(ordinal);
56 return value; 56 return value;
57 } 57 }
58 58
59 public sbyte GetSByte(string name) 59 public sbyte GetSByte(string name)
60 { 60 {
61 return (sbyte) m_source.GetInt16(m_source.GetOrdinal(name)); 61 return (sbyte) m_source.GetInt16(m_source.GetOrdinal(name));
62 } 62 }
63 63
64 //public Vector3 GetVector(string s) 64 //public Vector3 GetVector(string s)
65 //{ 65 //{
66 // float x = GetFloat(s + "X"); 66 // float x = GetFloat(s + "X");
67 // float y = GetFloat(s + "Y"); 67 // float y = GetFloat(s + "Y");
68 // float z = GetFloat(s + "Z"); 68 // float z = GetFloat(s + "Z");
69 69
70 // Vector3 vector = new Vector3(x, y, z); 70 // Vector3 vector = new Vector3(x, y, z);
71 71
72 // return vector; 72 // return vector;
73 //} 73 //}
74 74
75 //public Quaternion GetQuaternion(string s) 75 //public Quaternion GetQuaternion(string s)
76 //{ 76 //{
77 // float x = GetFloat(s + "X"); 77 // float x = GetFloat(s + "X");
78 // float y = GetFloat(s + "Y"); 78 // float y = GetFloat(s + "Y");
79 // float z = GetFloat(s + "Z"); 79 // float z = GetFloat(s + "Z");
80 // float w = GetFloat(s + "W"); 80 // float w = GetFloat(s + "W");
81 81
82 // Quaternion quaternion = new Quaternion(x, y, z, w); 82 // Quaternion quaternion = new Quaternion(x, y, z, w);
83 83
84 // return quaternion; 84 // return quaternion;
85 //} 85 //}
86 86
87 public float GetFloat(string name) 87 public float GetFloat(string name)
88 { 88 {
89 return m_source.GetFloat(m_source.GetOrdinal(name)); 89 return m_source.GetFloat(m_source.GetOrdinal(name));
90 } 90 }
91 91
92 public byte[] GetBytes(string name) 92 public byte[] GetBytes(string name)
93 { 93 {
94 int ordinal = m_source.GetOrdinal(name); 94 int ordinal = m_source.GetOrdinal(name);
95 95
96 if (m_source.GetValue(ordinal) == DBNull.Value) 96 if (m_source.GetValue(ordinal) == DBNull.Value)
97 { 97 {
98 return null; 98 return null;
99 } 99 }
100 100
101 byte[] buffer = new byte[16384]; 101 byte[] buffer = new byte[16384];
102 102
103 MemoryStream memStream = new MemoryStream(); 103 MemoryStream memStream = new MemoryStream();
104 104
105 long totalRead = 0; 105 long totalRead = 0;
106 106
107 int bytesRead; 107 int bytesRead;
108 do 108 do
109 { 109 {
110 bytesRead = (int) m_source.GetBytes(ordinal, totalRead, buffer, 0, buffer.Length); 110 bytesRead = (int) m_source.GetBytes(ordinal, totalRead, buffer, 0, buffer.Length);
111 totalRead += bytesRead; 111 totalRead += bytesRead;
112 112
113 memStream.Write(buffer, 0, bytesRead); 113 memStream.Write(buffer, 0, bytesRead);
114 } while (bytesRead == buffer.Length); 114 } while (bytesRead == buffer.Length);
115 115
116 return memStream.ToArray(); 116 return memStream.ToArray();
117 } 117 }
118 118
119 public string GetString(string name) 119 public string GetString(string name)
120 { 120 {
121 int ordinal = m_source.GetOrdinal(name); 121 int ordinal = m_source.GetOrdinal(name);
122 object value = m_source.GetValue(ordinal); 122 object value = m_source.GetValue(ordinal);
123 123
124 if (value is DBNull) 124 if (value is DBNull)
125 { 125 {
126 return null; 126 return null;
127 } 127 }
128 128
129 return (string) value; 129 return (string) value;
130 } 130 }
131 131
132 public bool Read() 132 public bool Read()
133 { 133 {
134 return m_source.Read(); 134 return m_source.Read();
135 } 135 }
136 136
137 internal Guid GetGuid(string name) 137 internal Guid GetGuid(string name)
138 { 138 {
139 string guidString = GetString(name); 139 string guidString = GetString(name);
140 if (String.IsNullOrEmpty(guidString)) 140 if (String.IsNullOrEmpty(guidString))
141 { 141 {
142 return Guid.Empty; 142 return Guid.Empty;
143 } 143 }
144 else 144 else
145 { 145 {
146 return new Guid(guidString); 146 return new Guid(guidString);
147 } 147 }
148 } 148 }
149 } 149 }
150} \ No newline at end of file 150} \ No newline at end of file