aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ThirdParty
diff options
context:
space:
mode:
authorlbsa712008-01-16 12:25:13 +0000
committerlbsa712008-01-16 12:25:13 +0000
commit5e757d2ad1ae3ad158a9b5f6077abcfaf9fac616 (patch)
tree96b3f4b939bd0c4a6e8b457f3e604ba143970c00 /ThirdParty
parent* Fix for: http://opensimulator.org/mantis/view.php?id=358 (diff)
downloadopensim-SC-5e757d2ad1ae3ad158a9b5f6077abcfaf9fac616.zip
opensim-SC-5e757d2ad1ae3ad158a9b5f6077abcfaf9fac616.tar.gz
opensim-SC-5e757d2ad1ae3ad158a9b5f6077abcfaf9fac616.tar.bz2
opensim-SC-5e757d2ad1ae3ad158a9b5f6077abcfaf9fac616.tar.xz
* More work on getting the database framework to actually work
Diffstat (limited to 'ThirdParty')
-rw-r--r--ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseDataReader.cs4
-rw-r--r--ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseDatabaseConnector.cs2
-rw-r--r--ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseFieldMapper.cs48
-rw-r--r--ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseRowMapper.cs37
-rw-r--r--ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseSchema.cs30
-rw-r--r--ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseTableMapper.cs12
6 files changed, 24 insertions, 109 deletions
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
31namespace TribalMedia.Framework.Data 31namespace 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;
29using System.Data.Common; 29using System.Data.Common;
30 30
31namespace TribalMedia.Framework.Data 31namespace 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
29namespace TribalMedia.Framework.Data 29namespace 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
30namespace TribalMedia.Framework.Data 30namespace 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