diff options
author | lbsa71 | 2008-01-16 12:25:13 +0000 |
---|---|---|
committer | lbsa71 | 2008-01-16 12:25:13 +0000 |
commit | 5e757d2ad1ae3ad158a9b5f6077abcfaf9fac616 (patch) | |
tree | 96b3f4b939bd0c4a6e8b457f3e604ba143970c00 | |
parent | * Fix for: http://opensimulator.org/mantis/view.php?id=358 (diff) | |
download | opensim-SC_OLD-5e757d2ad1ae3ad158a9b5f6077abcfaf9fac616.zip opensim-SC_OLD-5e757d2ad1ae3ad158a9b5f6077abcfaf9fac616.tar.gz opensim-SC_OLD-5e757d2ad1ae3ad158a9b5f6077abcfaf9fac616.tar.bz2 opensim-SC_OLD-5e757d2ad1ae3ad158a9b5f6077abcfaf9fac616.tar.xz |
* More work on getting the database framework to actually work
-rw-r--r-- | OpenSim/Framework/Data.MySQL/MySQLDatabaseMapper.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/Data/OpenSimDataReader.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/Data/OpenSimDatabaseConnector.cs (renamed from OpenSim/Framework/Data/OpenSimDatabaseMapper.cs) | 11 | ||||
-rw-r--r-- | OpenSim/Framework/Data/OpenSimObjectFieldMapper.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/Data/OpenSimTableMapper.cs | 5 | ||||
-rw-r--r-- | OpenSim/Framework/Data/PrimitiveBaseShapeTableMapper.cs | 8 | ||||
-rw-r--r-- | OpenSim/Region/ClientStack/ClientView.cs | 37 | ||||
-rw-r--r-- | ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseDataReader.cs | 4 | ||||
-rw-r--r-- | ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseDatabaseConnector.cs | 2 | ||||
-rw-r--r-- | ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseFieldMapper.cs | 48 | ||||
-rw-r--r-- | ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseRowMapper.cs | 37 | ||||
-rw-r--r-- | ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseSchema.cs | 30 | ||||
-rw-r--r-- | ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseTableMapper.cs | 12 |
13 files changed, 57 insertions, 143 deletions
diff --git a/OpenSim/Framework/Data.MySQL/MySQLDatabaseMapper.cs b/OpenSim/Framework/Data.MySQL/MySQLDatabaseMapper.cs index 6b23c74..ac5fb9d 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLDatabaseMapper.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLDatabaseMapper.cs | |||
@@ -3,7 +3,7 @@ using MySql.Data.MySqlClient; | |||
3 | 3 | ||
4 | namespace OpenSim.Framework.Data.MySQL | 4 | namespace OpenSim.Framework.Data.MySQL |
5 | { | 5 | { |
6 | public class MySQLDatabaseMapper : OpenSimDatabaseMapper | 6 | public class MySQLDatabaseMapper : OpenSimDatabaseConnector |
7 | { | 7 | { |
8 | public MySQLDatabaseMapper(string connectionString) | 8 | public MySQLDatabaseMapper(string connectionString) |
9 | : base(connectionString) | 9 | : base(connectionString) |
diff --git a/OpenSim/Framework/Data/OpenSimDataReader.cs b/OpenSim/Framework/Data/OpenSimDataReader.cs index 11a8b8b..518cdc9 100644 --- a/OpenSim/Framework/Data/OpenSimDataReader.cs +++ b/OpenSim/Framework/Data/OpenSimDataReader.cs | |||
@@ -7,7 +7,7 @@ using TribalMedia.Framework.Data; | |||
7 | 7 | ||
8 | namespace OpenSim.Framework.Data | 8 | namespace OpenSim.Framework.Data |
9 | { | 9 | { |
10 | public class OpenSimDataReader : DataReader | 10 | public class OpenSimDataReader : BaseDataReader |
11 | { | 11 | { |
12 | public OpenSimDataReader(IDataReader source) : base(source) | 12 | public OpenSimDataReader(IDataReader source) : base(source) |
13 | { | 13 | { |
diff --git a/OpenSim/Framework/Data/OpenSimDatabaseMapper.cs b/OpenSim/Framework/Data/OpenSimDatabaseConnector.cs index 4f202bc..ec80488 100644 --- a/OpenSim/Framework/Data/OpenSimDatabaseMapper.cs +++ b/OpenSim/Framework/Data/OpenSimDatabaseConnector.cs | |||
@@ -1,12 +1,12 @@ | |||
1 | using System.Data.Common; | 1 | using System.Data; |
2 | using libsecondlife; | 2 | using libsecondlife; |
3 | using TribalMedia.Framework.Data; | 3 | using TribalMedia.Framework.Data; |
4 | 4 | ||
5 | namespace OpenSim.Framework.Data | 5 | namespace OpenSim.Framework.Data |
6 | { | 6 | { |
7 | public abstract class OpenSimDatabaseMapper : BaseDatabaseConnector | 7 | public abstract class OpenSimDatabaseConnector : BaseDatabaseConnector |
8 | { | 8 | { |
9 | public OpenSimDatabaseMapper(string connectionString) : base(connectionString) | 9 | public OpenSimDatabaseConnector(string connectionString) : base(connectionString) |
10 | { | 10 | { |
11 | } | 11 | } |
12 | 12 | ||
@@ -19,5 +19,10 @@ namespace OpenSim.Framework.Data | |||
19 | 19 | ||
20 | return base.ConvertToDbType(value); | 20 | return base.ConvertToDbType(value); |
21 | } | 21 | } |
22 | |||
23 | public override BaseDataReader CreateReader(IDataReader reader) | ||
24 | { | ||
25 | return new OpenSimDataReader(reader); | ||
26 | } | ||
22 | } | 27 | } |
23 | } | 28 | } |
diff --git a/OpenSim/Framework/Data/OpenSimObjectFieldMapper.cs b/OpenSim/Framework/Data/OpenSimObjectFieldMapper.cs index d8c2ddf..103de2d 100644 --- a/OpenSim/Framework/Data/OpenSimObjectFieldMapper.cs +++ b/OpenSim/Framework/Data/OpenSimObjectFieldMapper.cs | |||
@@ -44,7 +44,7 @@ namespace OpenSim.Framework.Data | |||
44 | } | 44 | } |
45 | } | 45 | } |
46 | 46 | ||
47 | protected override object GetValue(DataReader reader) | 47 | protected override object GetValue(BaseDataReader reader) |
48 | { | 48 | { |
49 | object value; | 49 | object value; |
50 | 50 | ||
diff --git a/OpenSim/Framework/Data/OpenSimTableMapper.cs b/OpenSim/Framework/Data/OpenSimTableMapper.cs index a77936f..744f062 100644 --- a/OpenSim/Framework/Data/OpenSimTableMapper.cs +++ b/OpenSim/Framework/Data/OpenSimTableMapper.cs | |||
@@ -8,10 +8,5 @@ namespace OpenSim.Framework.Data | |||
8 | public OpenSimTableMapper(BaseDatabaseConnector database, string tableName) : base(database, tableName) | 8 | public OpenSimTableMapper(BaseDatabaseConnector database, string tableName) : base(database, tableName) |
9 | { | 9 | { |
10 | } | 10 | } |
11 | |||
12 | protected override DataReader CreateReader(IDataReader reader) | ||
13 | { | ||
14 | return new OpenSimDataReader(reader); | ||
15 | } | ||
16 | } | 11 | } |
17 | } | 12 | } |
diff --git a/OpenSim/Framework/Data/PrimitiveBaseShapeTableMapper.cs b/OpenSim/Framework/Data/PrimitiveBaseShapeTableMapper.cs index af49376..c915538 100644 --- a/OpenSim/Framework/Data/PrimitiveBaseShapeTableMapper.cs +++ b/OpenSim/Framework/Data/PrimitiveBaseShapeTableMapper.cs | |||
@@ -5,11 +5,11 @@ using libsecondlife; | |||
5 | 5 | ||
6 | namespace OpenSim.Framework.Data | 6 | namespace OpenSim.Framework.Data |
7 | { | 7 | { |
8 | public class PrimitiveBaseShapeRowMapper : RowMapper<PrimitiveBaseShape> | 8 | public class PrimitiveBaseShapeRowMapper : BaseRowMapper<PrimitiveBaseShape> |
9 | { | 9 | { |
10 | public Guid SceneObjectPartId; | 10 | public Guid SceneObjectPartId; |
11 | 11 | ||
12 | public PrimitiveBaseShapeRowMapper(Schema schema, PrimitiveBaseShape obj) : base(schema, obj) | 12 | public PrimitiveBaseShapeRowMapper(BaseSchema schema, PrimitiveBaseShape obj) : base(schema, obj) |
13 | { | 13 | { |
14 | } | 14 | } |
15 | } | 15 | } |
@@ -19,7 +19,7 @@ namespace OpenSim.Framework.Data | |||
19 | public PrimitiveBaseShapeTableMapper(BaseDatabaseConnector connection, string tableName) | 19 | public PrimitiveBaseShapeTableMapper(BaseDatabaseConnector connection, string tableName) |
20 | : base(connection, tableName) | 20 | : base(connection, tableName) |
21 | { | 21 | { |
22 | ObjectSchema<PrimitiveBaseShapeRowMapper> rowMapperSchema = new ObjectSchema<PrimitiveBaseShapeRowMapper>(this); | 22 | BaseSchema<PrimitiveBaseShapeRowMapper> rowMapperSchema = new BaseSchema<PrimitiveBaseShapeRowMapper>(this); |
23 | m_schema = rowMapperSchema; | 23 | m_schema = rowMapperSchema; |
24 | 24 | ||
25 | m_keyFieldMapper = rowMapperSchema.AddMapping<Guid>("SceneObjectPartId", | 25 | m_keyFieldMapper = rowMapperSchema.AddMapping<Guid>("SceneObjectPartId", |
@@ -111,7 +111,7 @@ namespace OpenSim.Framework.Data | |||
111 | delegate(PrimitiveBaseShapeRowMapper shape, byte[] value) { shape.Object.ExtraParams = value; }); | 111 | delegate(PrimitiveBaseShapeRowMapper shape, byte[] value) { shape.Object.ExtraParams = value; }); |
112 | } | 112 | } |
113 | 113 | ||
114 | public override PrimitiveBaseShapeRowMapper FromReader(DataReader reader) | 114 | public override PrimitiveBaseShapeRowMapper FromReader(BaseDataReader reader) |
115 | { | 115 | { |
116 | PrimitiveBaseShape shape = new PrimitiveBaseShape(); | 116 | PrimitiveBaseShape shape = new PrimitiveBaseShape(); |
117 | 117 | ||
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index e74aee7..d6c9d1d 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs | |||
@@ -416,7 +416,7 @@ namespace OpenSim.Region.ClientStack | |||
416 | { | 416 | { |
417 | // this will normally trigger at least one packet (ping response) | 417 | // this will normally trigger at least one packet (ping response) |
418 | SendStartPingCheck(0); | 418 | SendStartPingCheck(0); |
419 | 419 | ||
420 | } | 420 | } |
421 | } | 421 | } |
422 | else | 422 | else |
@@ -424,7 +424,7 @@ namespace OpenSim.Region.ClientStack | |||
424 | // Something received in the meantime - we can reset the counters | 424 | // Something received in the meantime - we can reset the counters |
425 | m_probesWithNoIngressPackets = 0; | 425 | m_probesWithNoIngressPackets = 0; |
426 | m_lastPacketsReceived = m_packetsReceived; | 426 | m_lastPacketsReceived = m_packetsReceived; |
427 | 427 | ||
428 | } | 428 | } |
429 | } | 429 | } |
430 | 430 | ||
@@ -2311,7 +2311,7 @@ namespace OpenSim.Region.ClientStack | |||
2311 | if (Pack.Header.Reliable) //DIRTY HACK | 2311 | if (Pack.Header.Reliable) //DIRTY HACK |
2312 | { | 2312 | { |
2313 | AddAck(Pack); // this adds the need to ack this packet later | 2313 | AddAck(Pack); // this adds the need to ack this packet later |
2314 | 2314 | ||
2315 | 2315 | ||
2316 | if (Pack.Type != PacketType.PacketAck && Pack.Type != PacketType.LogoutRequest) | 2316 | if (Pack.Type != PacketType.PacketAck && Pack.Type != PacketType.LogoutRequest) |
2317 | { | 2317 | { |
@@ -2355,10 +2355,15 @@ namespace OpenSim.Region.ClientStack | |||
2355 | { | 2355 | { |
2356 | lock (m_needAck) | 2356 | lock (m_needAck) |
2357 | { | 2357 | { |
2358 | foreach (uint ack in NewPack.Header.AckList) | 2358 | foreach (uint ackedPacketId in NewPack.Header.AckList) |
2359 | { | 2359 | { |
2360 | m_unAckedBytes -= m_needAck[ack].ToBytes().Length; | 2360 | Packet ackedPacket; |
2361 | m_needAck.Remove(ack); | 2361 | |
2362 | if (m_needAck.TryGetValue(ackedPacketId, out ackedPacket)) | ||
2363 | { | ||
2364 | m_unAckedBytes -= ackedPacket.ToBytes().Length; | ||
2365 | m_needAck.Remove(ackedPacketId); | ||
2366 | } | ||
2362 | } | 2367 | } |
2363 | } | 2368 | } |
2364 | } | 2369 | } |
@@ -2373,18 +2378,12 @@ namespace OpenSim.Region.ClientStack | |||
2373 | { | 2378 | { |
2374 | foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets) | 2379 | foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets) |
2375 | { | 2380 | { |
2376 | if (m_needAck.ContainsKey(block.ID)) | 2381 | uint ackedPackId = block.ID; |
2382 | Packet ackedPacket; | ||
2383 | if (m_needAck.TryGetValue(ackedPackId, out ackedPacket)) | ||
2377 | { | 2384 | { |
2378 | try | 2385 | m_unAckedBytes -= ackedPacket.ToBytes().Length; |
2379 | { | 2386 | m_needAck.Remove(ackedPackId); |
2380 | m_unAckedBytes -= m_needAck[block.ID].ToBytes().Length; | ||
2381 | m_needAck.Remove(block.ID); | ||
2382 | } | ||
2383 | catch (System.Collections.Generic.KeyNotFoundException) | ||
2384 | { | ||
2385 | // Did another packet come in with the ack already? | ||
2386 | // apparently so! | ||
2387 | } | ||
2388 | } | 2387 | } |
2389 | } | 2388 | } |
2390 | } | 2389 | } |
@@ -2500,11 +2499,11 @@ namespace OpenSim.Region.ClientStack | |||
2500 | 2499 | ||
2501 | protected void AckTimer_Elapsed(object sender, ElapsedEventArgs ea) | 2500 | protected void AckTimer_Elapsed(object sender, ElapsedEventArgs ea) |
2502 | { | 2501 | { |
2503 | 2502 | ||
2504 | SendAcks(); | 2503 | SendAcks(); |
2505 | ResendUnacked(); | 2504 | ResendUnacked(); |
2506 | SendPacketStats(); | 2505 | SendPacketStats(); |
2507 | 2506 | ||
2508 | } | 2507 | } |
2509 | 2508 | ||
2510 | protected void SendPacketStats() | 2509 | protected void SendPacketStats() |
diff --git a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseDataReader.cs b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseDataReader.cs index 34f894c..67fb7c1 100644 --- a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseDataReader.cs +++ b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseDataReader.cs | |||
@@ -30,11 +30,11 @@ using System.IO; | |||
30 | 30 | ||
31 | namespace TribalMedia.Framework.Data | 31 | namespace TribalMedia.Framework.Data |
32 | { | 32 | { |
33 | public class DataReader | 33 | public class BaseDataReader |
34 | { | 34 | { |
35 | private readonly IDataReader m_source; | 35 | private readonly IDataReader m_source; |
36 | 36 | ||
37 | public DataReader(IDataReader source) | 37 | public BaseDataReader(IDataReader source) |
38 | { | 38 | { |
39 | m_source = source; | 39 | m_source = source; |
40 | } | 40 | } |
diff --git a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseDatabaseConnector.cs b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseDatabaseConnector.cs index ae70fc1..e5d4d62 100644 --- a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseDatabaseConnector.cs +++ b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseDatabaseConnector.cs | |||
@@ -135,5 +135,7 @@ namespace TribalMedia.Framework.Data | |||
135 | { | 135 | { |
136 | return value; | 136 | return value; |
137 | } | 137 | } |
138 | |||
139 | public abstract BaseDataReader CreateReader(IDataReader reader); | ||
138 | } | 140 | } |
139 | } \ No newline at end of file | 141 | } \ No newline at end of file |
diff --git a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseFieldMapper.cs b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseFieldMapper.cs index 20d8cf1..20f919a 100644 --- a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseFieldMapper.cs +++ b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseFieldMapper.cs | |||
@@ -29,10 +29,7 @@ using System.Collections.Generic; | |||
29 | using System.Data.Common; | 29 | using System.Data.Common; |
30 | 30 | ||
31 | namespace TribalMedia.Framework.Data | 31 | namespace TribalMedia.Framework.Data |
32 | { | 32 | { |
33 | //public delegate TField RowMapperGetAccessor<TRowMapper, TField>(TRowMapper rowMapper); | ||
34 | //public delegate void RowMapperSetAccessor<TRowMapper, TField>(TRowMapper rowMapper, TField value); | ||
35 | |||
36 | public delegate TField ObjectGetAccessor<TObj, TField>(TObj obj); | 33 | public delegate TField ObjectGetAccessor<TObj, TField>(TObj obj); |
37 | public delegate void ObjectSetAccessor<TObj, TField>(TObj obj, TField value); | 34 | public delegate void ObjectSetAccessor<TObj, TField>(TObj obj, TField value); |
38 | 35 | ||
@@ -62,7 +59,7 @@ namespace TribalMedia.Framework.Data | |||
62 | m_tableMapper = tableMapper; | 59 | m_tableMapper = tableMapper; |
63 | } | 60 | } |
64 | 61 | ||
65 | public abstract void SetPropertyFromReader(object mapper, DataReader reader); | 62 | public abstract void SetPropertyFromReader(object mapper, BaseDataReader reader); |
66 | 63 | ||
67 | public void RawAddParam(DbCommand command, List<string> fieldNames, string fieldName, object value) | 64 | public void RawAddParam(DbCommand command, List<string> fieldNames, string fieldName, object value) |
68 | { | 65 | { |
@@ -84,7 +81,7 @@ namespace TribalMedia.Framework.Data | |||
84 | RawAddParam(command, fieldNames, fieldName, m_tableMapper.ConvertToDbType(value)); | 81 | RawAddParam(command, fieldNames, fieldName, m_tableMapper.ConvertToDbType(value)); |
85 | } | 82 | } |
86 | 83 | ||
87 | protected virtual object GetValue(DataReader reader) | 84 | protected virtual object GetValue(BaseDataReader reader) |
88 | { | 85 | { |
89 | object value; | 86 | object value; |
90 | 87 | ||
@@ -128,43 +125,6 @@ namespace TribalMedia.Framework.Data | |||
128 | } | 125 | } |
129 | } | 126 | } |
130 | 127 | ||
131 | //public class RowMapperField<TRowMapper, TField> : FieldMapper | ||
132 | // where TRowMapper : RowMapper | ||
133 | //{ | ||
134 | // private readonly RowMapperGetAccessor<TRowMapper, TField> m_fieldGetAccessor; | ||
135 | // private readonly RowMapperSetAccessor<TRowMapper, TField> m_fieldSetAccessor; | ||
136 | |||
137 | // public override object GetParamValue(object obj) | ||
138 | // { | ||
139 | // return m_fieldGetAccessor((TRowMapper) obj); | ||
140 | // } | ||
141 | |||
142 | // public override void SetPropertyFromReader(object mapper, DataReader reader) | ||
143 | // { | ||
144 | // object value; | ||
145 | |||
146 | // value = GetValue(reader); | ||
147 | |||
148 | // if (value == null) | ||
149 | // { | ||
150 | // m_fieldSetAccessor((TRowMapper) mapper, default(TField)); | ||
151 | // } | ||
152 | // else | ||
153 | // { | ||
154 | // m_fieldSetAccessor((TRowMapper) mapper, (TField) value); | ||
155 | // } | ||
156 | // } | ||
157 | |||
158 | |||
159 | // public RowMapperField(TableMapper tableMapper, string fieldName, RowMapperGetAccessor<TRowMapper, TField> rowMapperGetAccessor, | ||
160 | // RowMapperSetAccessor<TRowMapper, TField> rowMapperSetAccessor) | ||
161 | // : base(tableMapper, fieldName, typeof(TField)) | ||
162 | // { | ||
163 | // m_fieldGetAccessor = rowMapperGetAccessor; | ||
164 | // m_fieldSetAccessor = rowMapperSetAccessor; | ||
165 | // } | ||
166 | //} | ||
167 | |||
168 | public class ObjectField<TObject, TField> : BaseFieldMapper | 128 | public class ObjectField<TObject, TField> : BaseFieldMapper |
169 | { | 129 | { |
170 | private readonly ObjectGetAccessor<TObject, TField> m_fieldGetAccessor; | 130 | private readonly ObjectGetAccessor<TObject, TField> m_fieldGetAccessor; |
@@ -175,7 +135,7 @@ namespace TribalMedia.Framework.Data | |||
175 | return m_fieldGetAccessor((TObject)obj); | 135 | return m_fieldGetAccessor((TObject)obj); |
176 | } | 136 | } |
177 | 137 | ||
178 | public override void SetPropertyFromReader(object obj, DataReader reader) | 138 | public override void SetPropertyFromReader(object obj, BaseDataReader reader) |
179 | { | 139 | { |
180 | object value; | 140 | object value; |
181 | 141 | ||
diff --git a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseRowMapper.cs b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseRowMapper.cs index 2ab8daf..e8292fd 100644 --- a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseRowMapper.cs +++ b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseRowMapper.cs | |||
@@ -28,14 +28,14 @@ using TribalMedia.Framework.Data; | |||
28 | 28 | ||
29 | namespace TribalMedia.Framework.Data | 29 | namespace TribalMedia.Framework.Data |
30 | { | 30 | { |
31 | public abstract class RowMapper | 31 | public abstract class BaseRowMapper |
32 | { | 32 | { |
33 | public abstract void FillObject(DataReader reader); | 33 | public abstract void FillObject(BaseDataReader reader); |
34 | } | 34 | } |
35 | 35 | ||
36 | public class ObjectMapper<TObj> : RowMapper | 36 | public class BaseRowMapper<TObj> : BaseRowMapper |
37 | { | 37 | { |
38 | private readonly Schema m_schema; | 38 | private readonly BaseSchema m_schema; |
39 | private readonly TObj m_obj; | 39 | private readonly TObj m_obj; |
40 | 40 | ||
41 | public TObj Object | 41 | public TObj Object |
@@ -43,38 +43,13 @@ namespace TribalMedia.Framework.Data | |||
43 | get { return m_obj; } | 43 | get { return m_obj; } |
44 | } | 44 | } |
45 | 45 | ||
46 | public ObjectMapper(Schema schema, TObj obj) | 46 | public BaseRowMapper(BaseSchema schema, TObj obj) |
47 | { | 47 | { |
48 | m_schema = schema; | 48 | m_schema = schema; |
49 | m_obj = obj; | 49 | m_obj = obj; |
50 | } | 50 | } |
51 | 51 | ||
52 | public override void FillObject(DataReader reader) | 52 | public override void FillObject(BaseDataReader reader) |
53 | { | ||
54 | foreach (BaseFieldMapper fieldMapper in m_schema.Fields.Values) | ||
55 | { | ||
56 | fieldMapper.SetPropertyFromReader(m_obj, reader); | ||
57 | } | ||
58 | } | ||
59 | } | ||
60 | |||
61 | public class RowMapper<TObj> : RowMapper | ||
62 | { | ||
63 | private readonly Schema m_schema; | ||
64 | private readonly TObj m_obj; | ||
65 | |||
66 | public TObj Object | ||
67 | { | ||
68 | get { return m_obj; } | ||
69 | } | ||
70 | |||
71 | public RowMapper(Schema schema, TObj obj) | ||
72 | { | ||
73 | m_schema = schema; | ||
74 | m_obj = obj; | ||
75 | } | ||
76 | |||
77 | public override void FillObject(DataReader reader) | ||
78 | { | 53 | { |
79 | foreach (BaseFieldMapper fieldMapper in m_schema.Fields.Values) | 54 | foreach (BaseFieldMapper fieldMapper in m_schema.Fields.Values) |
80 | { | 55 | { |
diff --git a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseSchema.cs b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseSchema.cs index fc59f3b..a6740c2 100644 --- a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseSchema.cs +++ b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseSchema.cs | |||
@@ -29,7 +29,7 @@ using TribalMedia.Framework.Data; | |||
29 | 29 | ||
30 | namespace TribalMedia.Framework.Data | 30 | namespace TribalMedia.Framework.Data |
31 | { | 31 | { |
32 | public class Schema | 32 | public class BaseSchema |
33 | { | 33 | { |
34 | protected BaseTableMapper m_tableMapper; | 34 | protected BaseTableMapper m_tableMapper; |
35 | protected Dictionary<string, BaseFieldMapper> m_mappings; | 35 | protected Dictionary<string, BaseFieldMapper> m_mappings; |
@@ -39,16 +39,16 @@ namespace TribalMedia.Framework.Data | |||
39 | get { return m_mappings; } | 39 | get { return m_mappings; } |
40 | } | 40 | } |
41 | 41 | ||
42 | public Schema(BaseTableMapper tableMapper) | 42 | public BaseSchema(BaseTableMapper tableMapper) |
43 | { | 43 | { |
44 | m_mappings = new Dictionary<string, BaseFieldMapper>(); | 44 | m_mappings = new Dictionary<string, BaseFieldMapper>(); |
45 | m_tableMapper = tableMapper; | 45 | m_tableMapper = tableMapper; |
46 | } | 46 | } |
47 | } | 47 | } |
48 | 48 | ||
49 | public class ObjectSchema<TObj> : Schema | 49 | public class BaseSchema<TObj> : BaseSchema |
50 | { | 50 | { |
51 | public ObjectSchema(BaseTableMapper tableMapper) | 51 | public BaseSchema(BaseTableMapper tableMapper) |
52 | : base(tableMapper) | 52 | : base(tableMapper) |
53 | { | 53 | { |
54 | } | 54 | } |
@@ -65,26 +65,4 @@ namespace TribalMedia.Framework.Data | |||
65 | return rowMapperField; | 65 | return rowMapperField; |
66 | } | 66 | } |
67 | } | 67 | } |
68 | |||
69 | //public class RowMapperSchema<TRowMapper> : Schema | ||
70 | // where TRowMapper : RowMapper | ||
71 | //{ | ||
72 | // public RowMapperSchema(TableMapper tableMapper) : base(tableMapper) | ||
73 | // { | ||
74 | // } | ||
75 | |||
76 | // public RowMapperField<TRowMapper, TField> AddMapping<TField>(string fieldName, | ||
77 | // RowMapperGetAccessor<TRowMapper, TField> | ||
78 | // rowMapperGetAccessor, | ||
79 | // RowMapperSetAccessor<TRowMapper, TField> | ||
80 | // rowMapperSetAccessor) | ||
81 | // { | ||
82 | // RowMapperField<TRowMapper, TField> rowMapperField = | ||
83 | // new RowMapperField<TRowMapper, TField>(m_tableMapper, fieldName, rowMapperGetAccessor, rowMapperSetAccessor); | ||
84 | |||
85 | // m_mappings.Add(fieldName, rowMapperField); | ||
86 | |||
87 | // return rowMapperField; | ||
88 | // } | ||
89 | //} | ||
90 | } \ No newline at end of file | 68 | } \ No newline at end of file |
diff --git a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseTableMapper.cs b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseTableMapper.cs index e4fe0fd..e4ea055 100644 --- a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseTableMapper.cs +++ b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseTableMapper.cs | |||
@@ -62,8 +62,8 @@ namespace TribalMedia.Framework.Data | |||
62 | get { return m_tableName; } | 62 | get { return m_tableName; } |
63 | } | 63 | } |
64 | 64 | ||
65 | protected Schema m_schema; | 65 | protected BaseSchema m_schema; |
66 | public Schema Schema | 66 | public BaseSchema Schema |
67 | { | 67 | { |
68 | get { return m_schema; } | 68 | get { return m_schema; } |
69 | } | 69 | } |
@@ -110,9 +110,9 @@ namespace TribalMedia.Framework.Data | |||
110 | return m_database.ConvertToDbType(value); | 110 | return m_database.ConvertToDbType(value); |
111 | } | 111 | } |
112 | 112 | ||
113 | protected virtual DataReader CreateReader(IDataReader reader) | 113 | protected virtual BaseDataReader CreateReader(IDataReader reader) |
114 | { | 114 | { |
115 | return new DataReader(reader); | 115 | return m_database.CreateReader(reader); |
116 | } | 116 | } |
117 | } | 117 | } |
118 | 118 | ||
@@ -138,7 +138,7 @@ namespace TribalMedia.Framework.Data | |||
138 | { | 138 | { |
139 | if (reader.Read()) | 139 | if (reader.Read()) |
140 | { | 140 | { |
141 | result = FromReader(CreateReader(reader)); | 141 | result = FromReader( CreateReader(reader)); |
142 | success = true; | 142 | success = true; |
143 | } | 143 | } |
144 | else | 144 | else |
@@ -240,6 +240,6 @@ namespace TribalMedia.Framework.Data | |||
240 | } | 240 | } |
241 | } | 241 | } |
242 | 242 | ||
243 | public abstract TRowMapper FromReader(DataReader reader); | 243 | public abstract TRowMapper FromReader(BaseDataReader reader); |
244 | } | 244 | } |
245 | } \ No newline at end of file | 245 | } \ No newline at end of file |