diff options
author | lbsa71 | 2008-01-15 20:07:02 +0000 |
---|---|---|
committer | lbsa71 | 2008-01-15 20:07:02 +0000 |
commit | f5103b98be60cc8b1a69288328cdc20f78857835 (patch) | |
tree | b50381385478f57a05ed9fef7c5176397d76d2f2 /ThirdParty/TribalMedia/TribalMedia.Framework.Data/DataReader.cs | |
parent | * Added some comments to the linkset positioning code (diff) | |
download | opensim-SC-f5103b98be60cc8b1a69288328cdc20f78857835.zip opensim-SC-f5103b98be60cc8b1a69288328cdc20f78857835.tar.gz opensim-SC-f5103b98be60cc8b1a69288328cdc20f78857835.tar.bz2 opensim-SC-f5103b98be60cc8b1a69288328cdc20f78857835.tar.xz |
* Renamed a bunch of Data baseclasses for clarity and readability
(Slowly getting there)
Diffstat (limited to 'ThirdParty/TribalMedia/TribalMedia.Framework.Data/DataReader.cs')
-rw-r--r-- | ThirdParty/TribalMedia/TribalMedia.Framework.Data/DataReader.cs | 127 |
1 files changed, 0 insertions, 127 deletions
diff --git a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/DataReader.cs b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/DataReader.cs deleted file mode 100644 index 4792e9e..0000000 --- a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/DataReader.cs +++ /dev/null | |||
@@ -1,127 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Tribal Media AB, http://tribalmedia.se/ | ||
3 | * | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions are met: | ||
6 | * * Redistributions of source code must retain the above copyright | ||
7 | * notice, this list of conditions and the following disclaimer. | ||
8 | * * Redistributions in binary form must reproduce the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer in the | ||
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 | ||
12 | * derived from this software without specific prior written permission. | ||
13 | * | ||
14 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
15 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
17 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
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 | ||
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 | ||
23 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
24 | * | ||
25 | */ | ||
26 | |||
27 | using System; | ||
28 | using System.Data; | ||
29 | using System.IO; | ||
30 | |||
31 | namespace TribalMedia.Framework.Data | ||
32 | { | ||
33 | public class DataReader | ||
34 | { | ||
35 | private readonly IDataReader m_source; | ||
36 | |||
37 | public DataReader(IDataReader source) | ||
38 | { | ||
39 | m_source = source; | ||
40 | } | ||
41 | |||
42 | public object Get(string name) | ||
43 | { | ||
44 | return m_source[name]; | ||
45 | } | ||
46 | |||
47 | public ushort GetUShort(string name) | ||
48 | { | ||
49 | return (ushort) m_source.GetInt32(m_source.GetOrdinal(name)); | ||
50 | } | ||
51 | |||
52 | public byte GetByte(string name) | ||
53 | { | ||
54 | int ordinal = m_source.GetOrdinal(name); | ||
55 | byte value = (byte) m_source.GetInt16(ordinal); | ||
56 | return value; | ||
57 | } | ||
58 | |||
59 | public sbyte GetSByte(string name) | ||
60 | { | ||
61 | return (sbyte) m_source.GetInt16(m_source.GetOrdinal(name)); | ||
62 | } | ||
63 | |||
64 | public float GetFloat(string name) | ||
65 | { | ||
66 | return m_source.GetFloat(m_source.GetOrdinal(name)); | ||
67 | } | ||
68 | |||
69 | public byte[] GetBytes(string name) | ||
70 | { | ||
71 | int ordinal = m_source.GetOrdinal(name); | ||
72 | |||
73 | if (m_source.GetValue(ordinal) == DBNull.Value) | ||
74 | { | ||
75 | return null; | ||
76 | } | ||
77 | |||
78 | byte[] buffer = new byte[16384]; | ||
79 | |||
80 | MemoryStream memStream = new MemoryStream(); | ||
81 | |||
82 | long totalRead = 0; | ||
83 | |||
84 | int bytesRead; | ||
85 | do | ||
86 | { | ||
87 | bytesRead = (int) m_source.GetBytes(ordinal, totalRead, buffer, 0, buffer.Length); | ||
88 | totalRead += bytesRead; | ||
89 | |||
90 | memStream.Write(buffer, 0, bytesRead); | ||
91 | } while (bytesRead == buffer.Length); | ||
92 | |||
93 | return memStream.ToArray(); | ||
94 | } | ||
95 | |||
96 | public string GetString(string name) | ||
97 | { | ||
98 | int ordinal = m_source.GetOrdinal(name); | ||
99 | object value = m_source.GetValue(ordinal); | ||
100 | |||
101 | if (value is DBNull) | ||
102 | { | ||
103 | return null; | ||
104 | } | ||
105 | |||
106 | return (string) value; | ||
107 | } | ||
108 | |||
109 | public bool Read() | ||
110 | { | ||
111 | return m_source.Read(); | ||
112 | } | ||
113 | |||
114 | public Guid GetGuid(string name) | ||
115 | { | ||
116 | string guidString = GetString(name); | ||
117 | if (String.IsNullOrEmpty(guidString)) | ||
118 | { | ||
119 | return Guid.Empty; | ||
120 | } | ||
121 | else | ||
122 | { | ||
123 | return new Guid(guidString); | ||
124 | } | ||
125 | } | ||
126 | } | ||
127 | } \ No newline at end of file | ||