aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/Base
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/Base/AppearanceTableMapper.cs44
-rw-r--r--OpenSim/Data/Base/BaseDataReader.cs66
-rw-r--r--OpenSim/Data/Base/BaseDatabaseConnector.cs43
-rw-r--r--OpenSim/Data/Base/BaseFieldMapper.cs46
-rw-r--r--OpenSim/Data/Base/BaseRowMapper.cs19
-rw-r--r--OpenSim/Data/Base/BaseSchema.cs26
-rw-r--r--OpenSim/Data/Base/BaseTableMapper.cs151
7 files changed, 379 insertions, 16 deletions
diff --git a/OpenSim/Data/Base/AppearanceTableMapper.cs b/OpenSim/Data/Base/AppearanceTableMapper.cs
index 60acfe0..7964880 100644
--- a/OpenSim/Data/Base/AppearanceTableMapper.cs
+++ b/OpenSim/Data/Base/AppearanceTableMapper.cs
@@ -32,6 +32,9 @@ using OpenSim.Framework;
32 32
33namespace OpenSim.Data.Base 33namespace OpenSim.Data.Base
34{ 34{
35 /// <summary>
36 ///
37 /// </summary>
35 public class AppearanceRowMapper : BaseRowMapper<AvatarAppearance> 38 public class AppearanceRowMapper : BaseRowMapper<AvatarAppearance>
36 { 39 {
37 public AppearanceRowMapper(BaseSchema schema, AvatarAppearance obj) 40 public AppearanceRowMapper(BaseSchema schema, AvatarAppearance obj)
@@ -40,6 +43,9 @@ namespace OpenSim.Data.Base
40 } 43 }
41 } 44 }
42 45
46 /// <summary>
47 ///
48 /// </summary>
43 public class AppearanceTableMapper : BaseTableMapper<AppearanceRowMapper, Guid> 49 public class AppearanceTableMapper : BaseTableMapper<AppearanceRowMapper, Guid>
44 { 50 {
45 public AppearanceTableMapper(BaseDatabaseConnector database, string tableName) 51 public AppearanceTableMapper(BaseDatabaseConnector database, string tableName)
@@ -186,28 +192,55 @@ namespace OpenSim.Data.Base
186 192
187 } 193 }
188 194
195 /// <summary>
196 ///
197 /// </summary>
198 /// <param name="userID"></param>
199 /// <param name="appearance"></param>
200 /// <returns></returns>
189 public bool Add(Guid userID, AvatarAppearance appearance) 201 public bool Add(Guid userID, AvatarAppearance appearance)
190 { 202 {
191 AppearanceRowMapper mapper = CreateRowMapper(appearance); 203 AppearanceRowMapper mapper = CreateRowMapper(appearance);
192 return Add(mapper); 204 return Add(mapper);
193 } 205 }
194 206
207 /// <summary>
208 ///
209 /// </summary>
210 /// <param name="userID"></param>
211 /// <param name="appearance"></param>
212 /// <returns></returns>
195 public bool Update(Guid userID, AvatarAppearance appearance) 213 public bool Update(Guid userID, AvatarAppearance appearance)
196 { 214 {
197 AppearanceRowMapper mapper = CreateRowMapper(appearance); 215 AppearanceRowMapper mapper = CreateRowMapper(appearance);
198 return Update(appearance.Owner.UUID, mapper); 216 return Update(appearance.Owner.UUID, mapper);
199 } 217 }
200 218
219 /// <summary>
220 ///
221 /// </summary>
222 /// <param name="appearance"></param>
223 /// <returns></returns>
201 protected AppearanceRowMapper CreateRowMapper(AvatarAppearance appearance) 224 protected AppearanceRowMapper CreateRowMapper(AvatarAppearance appearance)
202 { 225 {
203 return new AppearanceRowMapper(m_schema, appearance); 226 return new AppearanceRowMapper(m_schema, appearance);
204 } 227 }
205 228
229 /// <summary>
230 ///
231 /// </summary>
232 /// <returns></returns>
206 protected AppearanceRowMapper CreateRowMapper() 233 protected AppearanceRowMapper CreateRowMapper()
207 { 234 {
208 return CreateRowMapper(new AvatarAppearance()); 235 return CreateRowMapper(new AvatarAppearance());
209 } 236 }
210 237
238 /// <summary>
239 ///
240 /// </summary>
241 /// <param name="reader"></param>
242 /// <param name="appearance"></param>
243 /// <returns></returns>
211 protected AppearanceRowMapper FromReader(BaseDataReader reader, AvatarAppearance appearance) 244 protected AppearanceRowMapper FromReader(BaseDataReader reader, AvatarAppearance appearance)
212 { 245 {
213 AppearanceRowMapper mapper = CreateRowMapper(appearance); 246 AppearanceRowMapper mapper = CreateRowMapper(appearance);
@@ -215,6 +248,11 @@ namespace OpenSim.Data.Base
215 return mapper; 248 return mapper;
216 } 249 }
217 250
251 /// <summary>
252 ///
253 /// </summary>
254 /// <param name="reader"></param>
255 /// <returns></returns>
218 public override AppearanceRowMapper FromReader(BaseDataReader reader) 256 public override AppearanceRowMapper FromReader(BaseDataReader reader)
219 { 257 {
220 AppearanceRowMapper mapper = CreateRowMapper(); 258 AppearanceRowMapper mapper = CreateRowMapper();
@@ -222,6 +260,12 @@ namespace OpenSim.Data.Base
222 return mapper; 260 return mapper;
223 } 261 }
224 262
263 /// <summary>
264 ///
265 /// </summary>
266 /// <param name="presenceID"></param>
267 /// <param name="val"></param>
268 /// <returns></returns>
225 public bool TryGetValue(Guid presenceID, out AvatarAppearance val) 269 public bool TryGetValue(Guid presenceID, out AvatarAppearance val)
226 { 270 {
227 AppearanceRowMapper mapper; 271 AppearanceRowMapper mapper;
diff --git a/OpenSim/Data/Base/BaseDataReader.cs b/OpenSim/Data/Base/BaseDataReader.cs
index 517f672..23f03e5 100644
--- a/OpenSim/Data/Base/BaseDataReader.cs
+++ b/OpenSim/Data/Base/BaseDataReader.cs
@@ -31,25 +31,47 @@ using System.IO;
31 31
32namespace OpenSim.Data.Base 32namespace OpenSim.Data.Base
33{ 33{
34 /// <summary>
35 ///
36 /// </summary>
34 public abstract class BaseDataReader 37 public abstract class BaseDataReader
35 { 38 {
36 private readonly IDataReader m_source; 39 private readonly IDataReader m_source;
37 40
41 /// <summary>
42 ///
43 /// </summary>
44 /// <param name="source"></param>
38 public BaseDataReader(IDataReader source) 45 public BaseDataReader(IDataReader source)
39 { 46 {
40 m_source = source; 47 m_source = source;
41 } 48 }
42 49
50 /// <summary>
51 ///
52 /// </summary>
53 /// <param name="name"></param>
54 /// <returns></returns>
43 public object Get(string name) 55 public object Get(string name)
44 { 56 {
45 return m_source[name]; 57 return m_source[name];
46 } 58 }
47 59
60 /// <summary>
61 ///
62 /// </summary>
63 /// <param name="name"></param>
64 /// <returns></returns>
48 public ushort GetUShort(string name) 65 public ushort GetUShort(string name)
49 { 66 {
50 return (ushort)m_source.GetInt32(m_source.GetOrdinal(name)); 67 return (ushort)m_source.GetInt32(m_source.GetOrdinal(name));
51 } 68 }
52 69
70 /// <summary>
71 ///
72 /// </summary>
73 /// <param name="name"></param>
74 /// <returns></returns>
53 public byte GetByte(string name) 75 public byte GetByte(string name)
54 { 76 {
55 int ordinal = m_source.GetOrdinal(name); 77 int ordinal = m_source.GetOrdinal(name);
@@ -57,16 +79,31 @@ namespace OpenSim.Data.Base
57 return value; 79 return value;
58 } 80 }
59 81
82 /// <summary>
83 ///
84 /// </summary>
85 /// <param name="name"></param>
86 /// <returns></returns>
60 public sbyte GetSByte(string name) 87 public sbyte GetSByte(string name)
61 { 88 {
62 return (sbyte)m_source.GetInt16(m_source.GetOrdinal(name)); 89 return (sbyte)m_source.GetInt16(m_source.GetOrdinal(name));
63 } 90 }
64 91
92 /// <summary>
93 ///
94 /// </summary>
95 /// <param name="name"></param>
96 /// <returns></returns>
65 public float GetFloat(string name) 97 public float GetFloat(string name)
66 { 98 {
67 return m_source.GetFloat(m_source.GetOrdinal(name)); 99 return m_source.GetFloat(m_source.GetOrdinal(name));
68 } 100 }
69 101
102 /// <summary>
103 ///
104 /// </summary>
105 /// <param name="name"></param>
106 /// <returns></returns>
70 public byte[] GetBytes(string name) 107 public byte[] GetBytes(string name)
71 { 108 {
72 int ordinal = m_source.GetOrdinal(name); 109 int ordinal = m_source.GetOrdinal(name);
@@ -94,6 +131,11 @@ namespace OpenSim.Data.Base
94 return memStream.ToArray(); 131 return memStream.ToArray();
95 } 132 }
96 133
134 /// <summary>
135 ///
136 /// </summary>
137 /// <param name="name"></param>
138 /// <returns></returns>
97 public string GetString(string name) 139 public string GetString(string name)
98 { 140 {
99 int ordinal = m_source.GetOrdinal(name); 141 int ordinal = m_source.GetOrdinal(name);
@@ -107,21 +149,40 @@ namespace OpenSim.Data.Base
107 return (string)value; 149 return (string)value;
108 } 150 }
109 151
152 /// <summary>
153 ///
154 /// </summary>
155 /// <returns></returns>
110 public bool Read() 156 public bool Read()
111 { 157 {
112 return m_source.Read(); 158 return m_source.Read();
113 } 159 }
114 160
161 /// <summary>
162 ///
163 /// </summary>
164 /// <param name="name"></param>
165 /// <returns></returns>
115 public virtual Guid GetGuid(string name) 166 public virtual Guid GetGuid(string name)
116 { 167 {
117 return m_source.GetGuid(m_source.GetOrdinal(name)); 168 return m_source.GetGuid(m_source.GetOrdinal(name));
118 } 169 }
119 170
171 /// <summary>
172 ///
173 /// </summary>
174 /// <param name="name"></param>
175 /// <returns></returns>
120 public UInt32 GetUInt32(string name) 176 public UInt32 GetUInt32(string name)
121 { 177 {
122 return (UInt32)GetInt32(name); 178 return (UInt32)GetInt32(name);
123 } 179 }
124 180
181 /// <summary>
182 ///
183 /// </summary>
184 /// <param name="name"></param>
185 /// <returns></returns>
125 private Int32 GetInt32(string name) 186 private Int32 GetInt32(string name)
126 { 187 {
127 int ordinal = m_source.GetOrdinal(name); 188 int ordinal = m_source.GetOrdinal(name);
@@ -129,6 +190,11 @@ namespace OpenSim.Data.Base
129 return int32; 190 return int32;
130 } 191 }
131 192
193 /// <summary>
194 ///
195 /// </summary>
196 /// <param name="name"></param>
197 /// <returns></returns>
132 public Int64 GetInt64(string name) 198 public Int64 GetInt64(string name)
133 { 199 {
134 int ordinal = m_source.GetOrdinal(name); 200 int ordinal = m_source.GetOrdinal(name);
diff --git a/OpenSim/Data/Base/BaseDatabaseConnector.cs b/OpenSim/Data/Base/BaseDatabaseConnector.cs
index 6988839..542004c 100644
--- a/OpenSim/Data/Base/BaseDatabaseConnector.cs
+++ b/OpenSim/Data/Base/BaseDatabaseConnector.cs
@@ -32,10 +32,17 @@ using System.Data.Common;
32 32
33namespace OpenSim.Data.Base 33namespace OpenSim.Data.Base
34{ 34{
35 /// <summary>
36 ///
37 /// </summary>
35 public abstract class BaseDatabaseConnector 38 public abstract class BaseDatabaseConnector
36 { 39 {
37 protected string m_connectionString; 40 protected string m_connectionString;
38 41
42 /// <summary>
43 ///
44 /// </summary>
45 /// <param name="connectionString"></param>
39 public BaseDatabaseConnector(string connectionString) 46 public BaseDatabaseConnector(string connectionString)
40 { 47 {
41 m_connectionString = connectionString; 48 m_connectionString = connectionString;
@@ -44,6 +51,14 @@ namespace OpenSim.Data.Base
44 public abstract DbConnection GetNewConnection(); 51 public abstract DbConnection GetNewConnection();
45 public abstract string CreateParamName(string fieldName); 52 public abstract string CreateParamName(string fieldName);
46 53
54 /// <summary>
55 ///
56 /// </summary>
57 /// <param name="mapper"></param>
58 /// <param name="connection"></param>
59 /// <param name="fieldName"></param>
60 /// <param name="key"></param>
61 /// <returns></returns>
47 public DbCommand CreateSelectCommand(BaseTableMapper mapper, DbConnection connection, string fieldName, object key) 62 public DbCommand CreateSelectCommand(BaseTableMapper mapper, DbConnection connection, string fieldName, object key)
48 { 63 {
49 string table = mapper.TableName; 64 string table = mapper.TableName;
@@ -61,6 +76,14 @@ namespace OpenSim.Data.Base
61 return command; 76 return command;
62 } 77 }
63 78
79 /// <summary>
80 ///
81 /// </summary>
82 /// <param name="mapper"></param>
83 /// <param name="command"></param>
84 /// <param name="fieldName"></param>
85 /// <param name="key"></param>
86 /// <returns></returns>
64 public string CreateCondition(BaseTableMapper mapper, DbCommand command, string fieldName, object key) 87 public string CreateCondition(BaseTableMapper mapper, DbCommand command, string fieldName, object key)
65 { 88 {
66 string keyFieldParamName = mapper.CreateParamName(fieldName); 89 string keyFieldParamName = mapper.CreateParamName(fieldName);
@@ -73,6 +96,14 @@ namespace OpenSim.Data.Base
73 return String.Format("{0}={1}", fieldName, keyFieldParamName); 96 return String.Format("{0}={1}", fieldName, keyFieldParamName);
74 } 97 }
75 98
99 /// <summary>
100 ///
101 /// </summary>
102 /// <param name="mapper"></param>
103 /// <param name="connection"></param>
104 /// <param name="rowMapper"></param>
105 /// <param name="primaryKey"></param>
106 /// <returns></returns>
76 public DbCommand CreateUpdateCommand(BaseTableMapper mapper, DbConnection connection, object rowMapper, object primaryKey) 107 public DbCommand CreateUpdateCommand(BaseTableMapper mapper, DbConnection connection, object rowMapper, object primaryKey)
77 { 108 {
78 string table = mapper.TableName; 109 string table = mapper.TableName;
@@ -105,6 +136,13 @@ namespace OpenSim.Data.Base
105 return command; 136 return command;
106 } 137 }
107 138
139 /// <summary>
140 ///
141 /// </summary>
142 /// <param name="mapper"></param>
143 /// <param name="connection"></param>
144 /// <param name="obj"></param>
145 /// <returns></returns>
108 public DbCommand CreateInsertCommand(BaseTableMapper mapper, DbConnection connection, object obj) 146 public DbCommand CreateInsertCommand(BaseTableMapper mapper, DbConnection connection, object obj)
109 { 147 {
110 string table = mapper.TableName; 148 string table = mapper.TableName;
@@ -132,6 +170,11 @@ namespace OpenSim.Data.Base
132 return command; 170 return command;
133 } 171 }
134 172
173 /// <summary>
174 ///
175 /// </summary>
176 /// <param name="value"></param>
177 /// <returns></returns>
135 public virtual object ConvertToDbType(object value) 178 public virtual object ConvertToDbType(object value)
136 { 179 {
137 return value; 180 return value;
diff --git a/OpenSim/Data/Base/BaseFieldMapper.cs b/OpenSim/Data/Base/BaseFieldMapper.cs
index 4fdc7b9..c7d6bc9 100644
--- a/OpenSim/Data/Base/BaseFieldMapper.cs
+++ b/OpenSim/Data/Base/BaseFieldMapper.cs
@@ -34,11 +34,17 @@ namespace OpenSim.Data.Base
34 public delegate TField ObjectGetAccessor<TObj, TField>(TObj obj); 34 public delegate TField ObjectGetAccessor<TObj, TField>(TObj obj);
35 public delegate void ObjectSetAccessor<TObj, TField>(TObj obj, TField value); 35 public delegate void ObjectSetAccessor<TObj, TField>(TObj obj, TField value);
36 36
37 /// <summary>
38 ///
39 /// </summary>
37 public abstract class BaseFieldMapper 40 public abstract class BaseFieldMapper
38 { 41 {
39 private readonly BaseTableMapper m_tableMapper; 42 private readonly BaseTableMapper m_tableMapper;
40 private readonly string m_fieldName; 43 private readonly string m_fieldName;
41 44
45 /// <summary>
46 ///
47 /// </summary>
42 public string FieldName 48 public string FieldName
43 { 49 {
44 get { return m_fieldName; } 50 get { return m_fieldName; }
@@ -46,6 +52,9 @@ namespace OpenSim.Data.Base
46 52
47 protected Type m_valueType; 53 protected Type m_valueType;
48 54
55 /// <summary>
56 ///
57 /// </summary>
49 public Type ValueType 58 public Type ValueType
50 { 59 {
51 get { return m_valueType; } 60 get { return m_valueType; }
@@ -53,6 +62,12 @@ namespace OpenSim.Data.Base
53 62
54 public abstract object GetParamValue(object obj); 63 public abstract object GetParamValue(object obj);
55 64
65 /// <summary>
66 ///
67 /// </summary>
68 /// <param name="tableMapper"></param>
69 /// <param name="fieldName"></param>
70 /// <param name="valueType"></param>
56 public BaseFieldMapper(BaseTableMapper tableMapper, string fieldName, Type valueType) 71 public BaseFieldMapper(BaseTableMapper tableMapper, string fieldName, Type valueType)
57 { 72 {
58 m_fieldName = fieldName; 73 m_fieldName = fieldName;
@@ -62,6 +77,13 @@ namespace OpenSim.Data.Base
62 77
63 public abstract void SetPropertyFromReader(object mapper, BaseDataReader reader); 78 public abstract void SetPropertyFromReader(object mapper, BaseDataReader reader);
64 79
80 /// <summary>
81 ///
82 /// </summary>
83 /// <param name="command"></param>
84 /// <param name="fieldNames"></param>
85 /// <param name="fieldName"></param>
86 /// <param name="value"></param>
65 public void RawAddParam(DbCommand command, List<string> fieldNames, string fieldName, object value) 87 public void RawAddParam(DbCommand command, List<string> fieldNames, string fieldName, object value)
66 { 88 {
67 string paramName = m_tableMapper.CreateParamName(fieldName); 89 string paramName = m_tableMapper.CreateParamName(fieldName);
@@ -74,6 +96,13 @@ namespace OpenSim.Data.Base
74 command.Parameters.Add(param); 96 command.Parameters.Add(param);
75 } 97 }
76 98
99 /// <summary>
100 ///
101 /// </summary>
102 /// <typeparam name="TObj"></typeparam>
103 /// <param name="obj"></param>
104 /// <param name="command"></param>
105 /// <param name="fieldNames"></param>
77 public virtual void ExpandField<TObj>(TObj obj, DbCommand command, List<string> fieldNames) 106 public virtual void ExpandField<TObj>(TObj obj, DbCommand command, List<string> fieldNames)
78 { 107 {
79 string fieldName = FieldName; 108 string fieldName = FieldName;
@@ -82,6 +111,11 @@ namespace OpenSim.Data.Base
82 RawAddParam(command, fieldNames, fieldName, m_tableMapper.ConvertToDbType(value)); 111 RawAddParam(command, fieldNames, fieldName, m_tableMapper.ConvertToDbType(value));
83 } 112 }
84 113
114 /// <summary>
115 ///
116 /// </summary>
117 /// <param name="reader"></param>
118 /// <returns></returns>
85 protected virtual object GetValue(BaseDataReader reader) 119 protected virtual object GetValue(BaseDataReader reader)
86 { 120 {
87 object value; 121 object value;
@@ -130,6 +164,11 @@ namespace OpenSim.Data.Base
130 } 164 }
131 } 165 }
132 166
167 /// <summary>
168 ///
169 /// </summary>
170 /// <typeparam name="TObject"></typeparam>
171 /// <typeparam name="TField"></typeparam>
133 public class ObjectField<TObject, TField> : BaseFieldMapper 172 public class ObjectField<TObject, TField> : BaseFieldMapper
134 { 173 {
135 private readonly ObjectGetAccessor<TObject, TField> m_fieldGetAccessor; 174 private readonly ObjectGetAccessor<TObject, TField> m_fieldGetAccessor;
@@ -157,6 +196,13 @@ namespace OpenSim.Data.Base
157 } 196 }
158 197
159 198
199 /// <summary>
200 ///
201 /// </summary>
202 /// <param name="tableMapper"></param>
203 /// <param name="fieldName"></param>
204 /// <param name="rowMapperGetAccessor"></param>
205 /// <param name="rowMapperSetAccessor"></param>
160 public ObjectField(BaseTableMapper tableMapper, string fieldName, ObjectGetAccessor<TObject, TField> rowMapperGetAccessor, 206 public ObjectField(BaseTableMapper tableMapper, string fieldName, ObjectGetAccessor<TObject, TField> rowMapperGetAccessor,
161 ObjectSetAccessor<TObject, TField> rowMapperSetAccessor) 207 ObjectSetAccessor<TObject, TField> rowMapperSetAccessor)
162 : base(tableMapper, fieldName, typeof(TField)) 208 : base(tableMapper, fieldName, typeof(TField))
diff --git a/OpenSim/Data/Base/BaseRowMapper.cs b/OpenSim/Data/Base/BaseRowMapper.cs
index a61ce49d..d07f9b3 100644
--- a/OpenSim/Data/Base/BaseRowMapper.cs
+++ b/OpenSim/Data/Base/BaseRowMapper.cs
@@ -27,27 +27,46 @@
27 27
28namespace OpenSim.Data.Base 28namespace OpenSim.Data.Base
29{ 29{
30 /// <summary>
31 ///
32 /// </summary>
30 public abstract class BaseRowMapper 33 public abstract class BaseRowMapper
31 { 34 {
32 public abstract void FillObject(BaseDataReader reader); 35 public abstract void FillObject(BaseDataReader reader);
33 } 36 }
34 37
38 /// <summary>
39 ///
40 /// </summary>
41 /// <typeparam name="TObj"></typeparam>
35 public class BaseRowMapper<TObj> : BaseRowMapper 42 public class BaseRowMapper<TObj> : BaseRowMapper
36 { 43 {
37 private readonly BaseSchema m_schema; 44 private readonly BaseSchema m_schema;
38 private readonly TObj m_obj; 45 private readonly TObj m_obj;
39 46
47 /// <summary>
48 ///
49 /// </summary>
40 public TObj Object 50 public TObj Object
41 { 51 {
42 get { return m_obj; } 52 get { return m_obj; }
43 } 53 }
44 54
55 /// <summary>
56 ///
57 /// </summary>
58 /// <param name="schema"></param>
59 /// <param name="obj"></param>
45 public BaseRowMapper(BaseSchema schema, TObj obj) 60 public BaseRowMapper(BaseSchema schema, TObj obj)
46 { 61 {
47 m_schema = schema; 62 m_schema = schema;
48 m_obj = obj; 63 m_obj = obj;
49 } 64 }
50 65
66 /// <summary>
67 ///
68 /// </summary>
69 /// <param name="reader"></param>
51 public override void FillObject(BaseDataReader reader) 70 public override void FillObject(BaseDataReader reader)
52 { 71 {
53 foreach (BaseFieldMapper fieldMapper in m_schema.Fields.Values) 72 foreach (BaseFieldMapper fieldMapper in m_schema.Fields.Values)
diff --git a/OpenSim/Data/Base/BaseSchema.cs b/OpenSim/Data/Base/BaseSchema.cs
index 656433f..9d69a40 100644
--- a/OpenSim/Data/Base/BaseSchema.cs
+++ b/OpenSim/Data/Base/BaseSchema.cs
@@ -29,16 +29,26 @@ using System.Collections.Generic;
29 29
30namespace OpenSim.Data.Base 30namespace OpenSim.Data.Base
31{ 31{
32 /// <summary>
33 ///
34 /// </summary>
32 public class BaseSchema 35 public class BaseSchema
33 { 36 {
34 protected BaseTableMapper m_tableMapper; 37 protected BaseTableMapper m_tableMapper;
35 protected Dictionary<string, BaseFieldMapper> m_mappings; 38 protected Dictionary<string, BaseFieldMapper> m_mappings;
36 39
40 /// <summary>
41 ///
42 /// </summary>
37 public Dictionary<string, BaseFieldMapper> Fields 43 public Dictionary<string, BaseFieldMapper> Fields
38 { 44 {
39 get { return m_mappings; } 45 get { return m_mappings; }
40 } 46 }
41 47
48 /// <summary>
49 ///
50 /// </summary>
51 /// <param name="tableMapper"></param>
42 public BaseSchema(BaseTableMapper tableMapper) 52 public BaseSchema(BaseTableMapper tableMapper)
43 { 53 {
44 m_mappings = new Dictionary<string, BaseFieldMapper>(); 54 m_mappings = new Dictionary<string, BaseFieldMapper>();
@@ -46,13 +56,29 @@ namespace OpenSim.Data.Base
46 } 56 }
47 } 57 }
48 58
59 /// <summary>
60 ///
61 /// </summary>
62 /// <typeparam name="TObj"></typeparam>
49 public class BaseSchema<TObj> : BaseSchema 63 public class BaseSchema<TObj> : BaseSchema
50 { 64 {
65 /// <summary>
66 ///
67 /// </summary>
68 /// <param name="tableMapper"></param>
51 public BaseSchema(BaseTableMapper tableMapper) 69 public BaseSchema(BaseTableMapper tableMapper)
52 : base(tableMapper) 70 : base(tableMapper)
53 { 71 {
54 } 72 }
55 73
74 /// <summary>
75 ///
76 /// </summary>
77 /// <typeparam name="TField"></typeparam>
78 /// <param name="fieldName"></param>
79 /// <param name="rowMapperGetAccessor"></param>
80 /// <param name="rowMapperSetAccessor"></param>
81 /// <returns></returns>
56 public ObjectField<TObj, TField> AddMapping<TField>(string fieldName, 82 public ObjectField<TObj, TField> AddMapping<TField>(string fieldName,
57 ObjectGetAccessor<TObj, TField> rowMapperGetAccessor, 83 ObjectGetAccessor<TObj, TField> rowMapperGetAccessor,
58 ObjectSetAccessor<TObj, TField> rowMapperSetAccessor) 84 ObjectSetAccessor<TObj, TField> rowMapperSetAccessor)
diff --git a/OpenSim/Data/Base/BaseTableMapper.cs b/OpenSim/Data/Base/BaseTableMapper.cs
index 649b228..28b7ac8 100644
--- a/OpenSim/Data/Base/BaseTableMapper.cs
+++ b/OpenSim/Data/Base/BaseTableMapper.cs
@@ -31,11 +31,18 @@ using System.Data.Common;
31 31
32namespace OpenSim.Data.Base 32namespace OpenSim.Data.Base
33{ 33{
34 /// <summary>
35 ///
36 /// </summary>
34 public abstract class BaseTableMapper 37 public abstract class BaseTableMapper
35 { 38 {
36 private readonly BaseDatabaseConnector m_database; 39 private readonly BaseDatabaseConnector m_database;
37 private readonly object m_syncRoot = new object(); 40 private readonly object m_syncRoot = new object();
38 41
42 /// <summary>
43 ///
44 /// </summary>
45 /// <param name="action"></param>
39 protected void WithConnection(Action<DbConnection> action) 46 protected void WithConnection(Action<DbConnection> action)
40 { 47 {
41 lock (m_syncRoot) 48 lock (m_syncRoot)
@@ -74,59 +81,124 @@ namespace OpenSim.Data.Base
74 get { return m_keyFieldMapper; } 81 get { return m_keyFieldMapper; }
75 } 82 }
76 83
84 /// <summary>
85 ///
86 /// </summary>
87 /// <param name="database"></param>
88 /// <param name="tableName"></param>
77 public BaseTableMapper(BaseDatabaseConnector database, string tableName) 89 public BaseTableMapper(BaseDatabaseConnector database, string tableName)
78 { 90 {
79 m_database = database; 91 m_database = database;
80 m_tableName = tableName.ToLower(); // Stupid MySQL hack. 92 m_tableName = tableName.ToLower(); // Stupid MySQL hack.
81 } 93 }
82 94
95 /// <summary>
96 ///
97 /// </summary>
98 /// <param name="fieldName"></param>
99 /// <returns></returns>
83 public string CreateParamName(string fieldName) 100 public string CreateParamName(string fieldName)
84 { 101 {
85 return m_database.CreateParamName(fieldName); 102 return m_database.CreateParamName(fieldName);
86 } 103 }
87 104
105 /// <summary>
106 ///
107 /// </summary>
108 /// <param name="connection"></param>
109 /// <param name="fieldName"></param>
110 /// <param name="primaryKey"></param>
111 /// <returns></returns>
88 protected DbCommand CreateSelectCommand(DbConnection connection, string fieldName, object primaryKey) 112 protected DbCommand CreateSelectCommand(DbConnection connection, string fieldName, object primaryKey)
89 { 113 {
90 return m_database.CreateSelectCommand(this, connection, fieldName, primaryKey); 114 return m_database.CreateSelectCommand(this, connection, fieldName, primaryKey);
91 } 115 }
92 116
117 /// <summary>
118 ///
119 /// </summary>
120 /// <param name="command"></param>
121 /// <param name="fieldName"></param>
122 /// <param name="key"></param>
123 /// <returns></returns>
93 public string CreateCondition(DbCommand command, string fieldName, object key) 124 public string CreateCondition(DbCommand command, string fieldName, object key)
94 { 125 {
95 return m_database.CreateCondition(this, command, fieldName, key); 126 return m_database.CreateCondition(this, command, fieldName, key);
96 } 127 }
97 128
129 /// <summary>
130 ///
131 /// </summary>
132 /// <param name="connection"></param>
133 /// <param name="obj"></param>
134 /// <returns></returns>
98 public DbCommand CreateInsertCommand(DbConnection connection, object obj) 135 public DbCommand CreateInsertCommand(DbConnection connection, object obj)
99 { 136 {
100 return m_database.CreateInsertCommand(this, connection, obj); 137 return m_database.CreateInsertCommand(this, connection, obj);
101 } 138 }
102 139
140 /// <summary>
141 ///
142 /// </summary>
143 /// <param name="connection"></param>
144 /// <param name="rowMapper"></param>
145 /// <param name="primaryKey"></param>
146 /// <returns></returns>
103 public DbCommand CreateUpdateCommand(DbConnection connection, object rowMapper, object primaryKey) 147 public DbCommand CreateUpdateCommand(DbConnection connection, object rowMapper, object primaryKey)
104 { 148 {
105 return m_database.CreateUpdateCommand(this, connection, rowMapper, primaryKey); 149 return m_database.CreateUpdateCommand(this, connection, rowMapper, primaryKey);
106 } 150 }
107 151
152 /// <summary>
153 ///
154 /// </summary>
155 /// <param name="value"></param>
156 /// <returns></returns>
108 public object ConvertToDbType(object value) 157 public object ConvertToDbType(object value)
109 { 158 {
110 return m_database.ConvertToDbType(value); 159 return m_database.ConvertToDbType(value);
111 } 160 }
112 161
162 /// <summary>
163 ///
164 /// </summary>
165 /// <param name="reader"></param>
166 /// <returns></returns>
113 protected virtual BaseDataReader CreateReader(IDataReader reader) 167 protected virtual BaseDataReader CreateReader(IDataReader reader)
114 { 168 {
115 return m_database.CreateReader(reader); 169 return m_database.CreateReader(reader);
116 } 170 }
117 } 171 }
118 172
173 /// <summary>
174 ///
175 /// </summary>
176 /// <typeparam name="TRowMapper"></typeparam>
177 /// <typeparam name="TPrimaryKey"></typeparam>
119 public abstract class BaseTableMapper<TRowMapper, TPrimaryKey> : BaseTableMapper 178 public abstract class BaseTableMapper<TRowMapper, TPrimaryKey> : BaseTableMapper
120 { 179 {
180 /// <summary>
181 ///
182 /// </summary>
183 /// <param name="database"></param>
184 /// <param name="tableName"></param>
121 public BaseTableMapper(BaseDatabaseConnector database, string tableName) 185 public BaseTableMapper(BaseDatabaseConnector database, string tableName)
122 : base(database, tableName) 186 : base(database, tableName)
123 { 187 {
124 } 188 }
125 189
126 // HACK: This is a temporary function used by TryGetValue(). 190
127 // Due to a bug in mono 1.2.6, delegate blocks cannot contain 191
128 // a using block. This has been fixed in SVN, so the next 192 /// <summary>
129 // mono release should work. 193 /// HACK: This is a temporary function used by TryGetValue().
194 /// Due to a bug in mono 1.2.6, delegate blocks cannot contain
195 /// a using block. This has been fixed in SVN, so the next
196 /// mono release should work.
197 /// </summary>
198 /// <param name="connection"></param>
199 /// <param name="primaryKey"></param>
200 /// <param name="result"></param>
201 /// <param name="success"></param>
130 private void TryGetConnectionValue(DbConnection connection, TPrimaryKey primaryKey, ref TRowMapper result, ref bool success) 202 private void TryGetConnectionValue(DbConnection connection, TPrimaryKey primaryKey, ref TRowMapper result, ref bool success)
131 { 203 {
132 using ( 204 using (
@@ -148,6 +220,12 @@ namespace OpenSim.Data.Base
148 } 220 }
149 } 221 }
150 222
223 /// <summary>
224 ///
225 /// </summary>
226 /// <param name="primaryKey"></param>
227 /// <param name="value"></param>
228 /// <returns></returns>
151 public bool TryGetValue(TPrimaryKey primaryKey, out TRowMapper value) 229 public bool TryGetValue(TPrimaryKey primaryKey, out TRowMapper value)
152 { 230 {
153 TRowMapper result = default(TRowMapper); 231 TRowMapper result = default(TRowMapper);
@@ -163,10 +241,15 @@ namespace OpenSim.Data.Base
163 return success; 241 return success;
164 } 242 }
165 243
166 // HACK: This is a temporary function used by Remove(). 244 /// <summary>
167 // Due to a bug in mono 1.2.6, delegate blocks cannot contain 245 /// HACK: This is a temporary function used by Remove().
168 // a using block. This has been fixed in SVN, so the next 246 /// Due to a bug in mono 1.2.6, delegate blocks cannot contain
169 // mono release should work. 247 /// a using block. This has been fixed in SVN, so the next
248 /// mono release should work.
249 /// </summary>
250 /// <param name="connection"></param>
251 /// <param name="id"></param>
252 /// <param name="deleted"></param>
170 protected virtual void TryDelete(DbConnection connection, TPrimaryKey id, ref int deleted) 253 protected virtual void TryDelete(DbConnection connection, TPrimaryKey id, ref int deleted)
171 { 254 {
172 using ( 255 using (
@@ -177,6 +260,11 @@ namespace OpenSim.Data.Base
177 } 260 }
178 } 261 }
179 262
263 /// <summary>
264 ///
265 /// </summary>
266 /// <param name="id"></param>
267 /// <returns></returns>
180 public virtual bool Remove(TPrimaryKey id) 268 public virtual bool Remove(TPrimaryKey id)
181 { 269 {
182 int deleted = 0; 270 int deleted = 0;
@@ -196,6 +284,13 @@ namespace OpenSim.Data.Base
196 } 284 }
197 } 285 }
198 286
287 /// <summary>
288 ///
289 /// </summary>
290 /// <param name="connection"></param>
291 /// <param name="fieldName"></param>
292 /// <param name="primaryKey"></param>
293 /// <returns></returns>
199 public DbCommand CreateDeleteCommand(DbConnection connection, string fieldName, TPrimaryKey primaryKey) 294 public DbCommand CreateDeleteCommand(DbConnection connection, string fieldName, TPrimaryKey primaryKey)
200 { 295 {
201 string table = TableName; 296 string table = TableName;
@@ -213,10 +308,18 @@ namespace OpenSim.Data.Base
213 return command; 308 return command;
214 } 309 }
215 310
216 // HACK: This is a temporary function used by Update(). 311
217 // Due to a bug in mono 1.2.6, delegate blocks cannot contain 312
218 // a using block. This has been fixed in SVN, so the next 313 /// <summary>
219 // mono release should work. 314 /// HACK: This is a temporary function used by Update().
315 /// Due to a bug in mono 1.2.6, delegate blocks cannot contain
316 /// a using block. This has been fixed in SVN, so the next
317 /// mono release should work.
318 /// </summary>
319 /// <param name="connection"></param>
320 /// <param name="primaryKey"></param>
321 /// <param name="value"></param>
322 /// <param name="updated"></param>
220 protected void TryUpdate(DbConnection connection, TPrimaryKey primaryKey, TRowMapper value, ref int updated) 323 protected void TryUpdate(DbConnection connection, TPrimaryKey primaryKey, TRowMapper value, ref int updated)
221 { 324 {
222 using (DbCommand command = CreateUpdateCommand(connection, value, primaryKey)) 325 using (DbCommand command = CreateUpdateCommand(connection, value, primaryKey))
@@ -225,6 +328,12 @@ namespace OpenSim.Data.Base
225 } 328 }
226 } 329 }
227 330
331 /// <summary>
332 ///
333 /// </summary>
334 /// <param name="primaryKey"></param>
335 /// <param name="value"></param>
336 /// <returns></returns>
228 public virtual bool Update(TPrimaryKey primaryKey, TRowMapper value) 337 public virtual bool Update(TPrimaryKey primaryKey, TRowMapper value)
229 { 338 {
230 int updated = 0; 339 int updated = 0;
@@ -244,10 +353,15 @@ namespace OpenSim.Data.Base
244 } 353 }
245 } 354 }
246 355
247 // HACK: This is a temporary function used by Add(). 356 /// <summary>
248 // Due to a bug in mono 1.2.6, delegate blocks cannot contain 357 /// HACK: This is a temporary function used by Add().
249 // a using block. This has been fixed in SVN, so the next 358 /// Due to a bug in mono 1.2.6, delegate blocks cannot contain
250 // mono release should work. 359 /// a using block. This has been fixed in SVN, so the next
360 /// mono release should work.
361 /// </summary>
362 /// <param name="connection"></param>
363 /// <param name="value"></param>
364 /// <param name="added"></param>
251 protected void TryAdd(DbConnection connection, TRowMapper value, ref int added) 365 protected void TryAdd(DbConnection connection, TRowMapper value, ref int added)
252 { 366 {
253 using (DbCommand command = CreateInsertCommand(connection, value)) 367 using (DbCommand command = CreateInsertCommand(connection, value))
@@ -256,6 +370,11 @@ namespace OpenSim.Data.Base
256 } 370 }
257 } 371 }
258 372
373 /// <summary>
374 ///
375 /// </summary>
376 /// <param name="value"></param>
377 /// <returns></returns>
259 public virtual bool Add(TRowMapper value) 378 public virtual bool Add(TRowMapper value)
260 { 379 {
261 int added = 0; 380 int added = 0;