From f5103b98be60cc8b1a69288328cdc20f78857835 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 15 Jan 2008 20:07:02 +0000 Subject: [PATCH] * Renamed a bunch of Data baseclasses for clarity and readability (Slowly getting there) --- .../Framework/Data/OpenSimDatabaseMapper.cs | 2 +- .../Data/OpenSimObjectFieldMapper.cs | 4 +- OpenSim/Framework/Data/OpenSimTableMapper.cs | 4 +- .../Data/PrimitiveBaseShapeTableMapper.cs | 4 +- .../{DataReader.cs => BaseDataReader.cs} | 10 +- ...baseMapper.cs => BaseDatabaseConnector.cs} | 16 +-- .../{FieldMapper.cs => BaseFieldMapper.cs} | 126 +++++++++--------- .../{RowMapper.cs => BaseRowMapper.cs} | 4 +- .../{Schema.cs => BaseSchema.cs} | 49 +++---- ...bjectTableMapper.cs => BaseTableMapper.cs} | 94 ++++++++++++- .../TribalMedia.Framework.Data/TableMapper.cs | 118 ---------------- .../TribalMedia.Framework.Data.snk | Bin 0 -> 596 bytes 12 files changed, 199 insertions(+), 232 deletions(-) rename ThirdParty/TribalMedia/TribalMedia.Framework.Data/{DataReader.cs => BaseDataReader.cs} (91%) rename ThirdParty/TribalMedia/TribalMedia.Framework.Data/{DatabaseMapper.cs => BaseDatabaseConnector.cs} (85%) rename ThirdParty/TribalMedia/TribalMedia.Framework.Data/{FieldMapper.cs => BaseFieldMapper.cs} (60%) rename ThirdParty/TribalMedia/TribalMedia.Framework.Data/{RowMapper.cs => BaseRowMapper.cs} (94%) rename ThirdParty/TribalMedia/TribalMedia.Framework.Data/{Schema.cs => BaseSchema.cs} (63%) rename ThirdParty/TribalMedia/TribalMedia.Framework.Data/{ObjectTableMapper.cs => BaseTableMapper.cs} (67%) delete mode 100644 ThirdParty/TribalMedia/TribalMedia.Framework.Data/TableMapper.cs create mode 100644 ThirdParty/TribalMedia/TribalMedia.Framework.Data/TribalMedia.Framework.Data.snk diff --git a/OpenSim/Framework/Data/OpenSimDatabaseMapper.cs b/OpenSim/Framework/Data/OpenSimDatabaseMapper.cs index bb8246252c..4f202bc8c0 100644 --- a/OpenSim/Framework/Data/OpenSimDatabaseMapper.cs +++ b/OpenSim/Framework/Data/OpenSimDatabaseMapper.cs @@ -4,7 +4,7 @@ using TribalMedia.Framework.Data; namespace OpenSim.Framework.Data { - public abstract class OpenSimDatabaseMapper : DatabaseMapper + public abstract class OpenSimDatabaseMapper : BaseDatabaseConnector { public OpenSimDatabaseMapper(string connectionString) : base(connectionString) { diff --git a/OpenSim/Framework/Data/OpenSimObjectFieldMapper.cs b/OpenSim/Framework/Data/OpenSimObjectFieldMapper.cs index 851ebcd450..d8c2ddf337 100644 --- a/OpenSim/Framework/Data/OpenSimObjectFieldMapper.cs +++ b/OpenSim/Framework/Data/OpenSimObjectFieldMapper.cs @@ -9,7 +9,7 @@ namespace OpenSim.Framework.Data { public class OpenSimObjectFieldMapper : ObjectField { - public OpenSimObjectFieldMapper(TableMapper tableMapper, string fieldName, + public OpenSimObjectFieldMapper(BaseTableMapper tableMapper, string fieldName, ObjectGetAccessor rowMapperGetAccessor, ObjectSetAccessor rowMapperSetAccessor) : base(tableMapper, fieldName, rowMapperGetAccessor, rowMapperSetAccessor) @@ -40,7 +40,7 @@ namespace OpenSim.Framework.Data } else { - base.ExpandField(obj, command, fieldNames); + base.ExpandField(obj, command, fieldNames); } } diff --git a/OpenSim/Framework/Data/OpenSimTableMapper.cs b/OpenSim/Framework/Data/OpenSimTableMapper.cs index c72f523a99..b6406b6336 100644 --- a/OpenSim/Framework/Data/OpenSimTableMapper.cs +++ b/OpenSim/Framework/Data/OpenSimTableMapper.cs @@ -3,9 +3,9 @@ using TribalMedia.Framework.Data; namespace OpenSim.Framework.Data { - public abstract class OpenSimTableMapper : ObjectTableMapper + public abstract class OpenSimTableMapper : BaseTableMapper { - public OpenSimTableMapper(DatabaseMapper database, string tableName) : base(database, tableName) + public OpenSimTableMapper(BaseDatabaseConnector database, string tableName) : base(database, tableName) { } diff --git a/OpenSim/Framework/Data/PrimitiveBaseShapeTableMapper.cs b/OpenSim/Framework/Data/PrimitiveBaseShapeTableMapper.cs index c8098ab0ce..af49376521 100644 --- a/OpenSim/Framework/Data/PrimitiveBaseShapeTableMapper.cs +++ b/OpenSim/Framework/Data/PrimitiveBaseShapeTableMapper.cs @@ -16,10 +16,10 @@ namespace OpenSim.Framework.Data public class PrimitiveBaseShapeTableMapper : OpenSimTableMapper { - public PrimitiveBaseShapeTableMapper(DatabaseMapper connection, string tableName) + public PrimitiveBaseShapeTableMapper(BaseDatabaseConnector connection, string tableName) : base(connection, tableName) { - RowMapperSchema rowMapperSchema = new RowMapperSchema(this); + ObjectSchema rowMapperSchema = new ObjectSchema(this); m_schema = rowMapperSchema; m_keyFieldMapper = rowMapperSchema.AddMapping("SceneObjectPartId", diff --git a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/DataReader.cs b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseDataReader.cs similarity index 91% rename from ThirdParty/TribalMedia/TribalMedia.Framework.Data/DataReader.cs rename to ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseDataReader.cs index 4792e9e4c4..34f894c6c2 100644 --- a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/DataReader.cs +++ b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseDataReader.cs @@ -46,19 +46,19 @@ namespace TribalMedia.Framework.Data public ushort GetUShort(string name) { - return (ushort) m_source.GetInt32(m_source.GetOrdinal(name)); + return (ushort)m_source.GetInt32(m_source.GetOrdinal(name)); } public byte GetByte(string name) { int ordinal = m_source.GetOrdinal(name); - byte value = (byte) m_source.GetInt16(ordinal); + byte value = (byte)m_source.GetInt16(ordinal); return value; } public sbyte GetSByte(string name) { - return (sbyte) m_source.GetInt16(m_source.GetOrdinal(name)); + return (sbyte)m_source.GetInt16(m_source.GetOrdinal(name)); } public float GetFloat(string name) @@ -84,7 +84,7 @@ namespace TribalMedia.Framework.Data int bytesRead; do { - bytesRead = (int) m_source.GetBytes(ordinal, totalRead, buffer, 0, buffer.Length); + bytesRead = (int)m_source.GetBytes(ordinal, totalRead, buffer, 0, buffer.Length); totalRead += bytesRead; memStream.Write(buffer, 0, bytesRead); @@ -103,7 +103,7 @@ namespace TribalMedia.Framework.Data return null; } - return (string) value; + return (string)value; } public bool Read() diff --git a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/DatabaseMapper.cs b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseDatabaseConnector.cs similarity index 85% rename from ThirdParty/TribalMedia/TribalMedia.Framework.Data/DatabaseMapper.cs rename to ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseDatabaseConnector.cs index 63e59aa634..ae70fc1fe3 100644 --- a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/DatabaseMapper.cs +++ b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseDatabaseConnector.cs @@ -31,11 +31,11 @@ using System.Data.Common; namespace TribalMedia.Framework.Data { - public abstract class DatabaseMapper + public abstract class BaseDatabaseConnector { protected string m_connectionString; - public DatabaseMapper(string connectionString) + public BaseDatabaseConnector(string connectionString) { m_connectionString = connectionString; } @@ -43,7 +43,7 @@ namespace TribalMedia.Framework.Data public abstract DbConnection GetNewConnection(); public abstract string CreateParamName(string fieldName); - public DbCommand CreateSelectCommand(TableMapper mapper, DbConnection connection, string fieldName, object key) + public DbCommand CreateSelectCommand(BaseTableMapper mapper, DbConnection connection, string fieldName, object key) { string table = mapper.TableName; @@ -60,7 +60,7 @@ namespace TribalMedia.Framework.Data return command; } - public string CreateCondition(TableMapper mapper, DbCommand command, string fieldName, object key) + public string CreateCondition(BaseTableMapper mapper, DbCommand command, string fieldName, object key) { string keyFieldParamName = mapper.CreateParamName(fieldName); @@ -72,7 +72,7 @@ namespace TribalMedia.Framework.Data return String.Format("{0}={1}", fieldName, keyFieldParamName); } - public DbCommand CreateUpdateCommand(TableMapper mapper, DbConnection connection, object rowMapper, object primaryKey) + public DbCommand CreateUpdateCommand(BaseTableMapper mapper, DbConnection connection, object rowMapper, object primaryKey) { string table = mapper.TableName; @@ -80,7 +80,7 @@ namespace TribalMedia.Framework.Data DbCommand command = connection.CreateCommand(); - foreach (FieldMapper fieldMapper in mapper.Schema.Fields.Values) + foreach (BaseFieldMapper fieldMapper in mapper.Schema.Fields.Values) { if (fieldMapper != mapper.KeyFieldMapper) { @@ -104,7 +104,7 @@ namespace TribalMedia.Framework.Data return command; } - public DbCommand CreateInsertCommand(TableMapper mapper, DbConnection connection, object obj) + public DbCommand CreateInsertCommand(BaseTableMapper mapper, DbConnection connection, object obj) { string table = mapper.TableName; @@ -112,7 +112,7 @@ namespace TribalMedia.Framework.Data DbCommand command = connection.CreateCommand(); - foreach (FieldMapper fieldMapper in mapper.Schema.Fields.Values) + foreach (BaseFieldMapper fieldMapper in mapper.Schema.Fields.Values) { fieldMapper.ExpandField(obj, command, fieldNames); } diff --git a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/FieldMapper.cs b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseFieldMapper.cs similarity index 60% rename from ThirdParty/TribalMedia/TribalMedia.Framework.Data/FieldMapper.cs rename to ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseFieldMapper.cs index 89bc0f0efc..20d8cf1762 100644 --- a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/FieldMapper.cs +++ b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseFieldMapper.cs @@ -30,17 +30,15 @@ using System.Data.Common; namespace TribalMedia.Framework.Data { - public delegate TField RowMapperGetAccessor(TRowMapper rowMapper); - - public delegate void RowMapperSetAccessor(TRowMapper rowMapper, TField value); + //public delegate TField RowMapperGetAccessor(TRowMapper rowMapper); + //public delegate void RowMapperSetAccessor(TRowMapper rowMapper, TField value); public delegate TField ObjectGetAccessor(TObj obj); - public delegate void ObjectSetAccessor(TObj obj, TField value); - public abstract class FieldMapper + public abstract class BaseFieldMapper { - private readonly TableMapper m_tableMapper; + private readonly BaseTableMapper m_tableMapper; private readonly string m_fieldName; public string FieldName @@ -57,7 +55,7 @@ namespace TribalMedia.Framework.Data public abstract object GetParamValue(object obj); - public FieldMapper( TableMapper tableMapper, string fieldName, Type valueType) + public BaseFieldMapper(BaseTableMapper tableMapper, string fieldName, Type valueType) { m_fieldName = fieldName; m_valueType = valueType; @@ -94,32 +92,32 @@ namespace TribalMedia.Framework.Data { value = reader.GetGuid(m_fieldName); } - else if (ValueType == typeof (bool)) + else if (ValueType == typeof(bool)) { uint boolVal = reader.GetUShort(m_fieldName); value = (boolVal == 1); } - else - if (ValueType == typeof (byte)) - { - value = reader.GetByte(m_fieldName); - } - else if (ValueType == typeof (sbyte)) - { - value = reader.GetSByte(m_fieldName); - } - else if (ValueType == typeof (ushort)) - { - value = reader.GetUShort(m_fieldName); - } - else if (ValueType == typeof (byte[])) - { - value = reader.GetBytes(m_fieldName); - } else - { - value = reader.Get(m_fieldName); - } + if (ValueType == typeof(byte)) + { + value = reader.GetByte(m_fieldName); + } + else if (ValueType == typeof(sbyte)) + { + value = reader.GetSByte(m_fieldName); + } + else if (ValueType == typeof(ushort)) + { + value = reader.GetUShort(m_fieldName); + } + else if (ValueType == typeof(byte[])) + { + value = reader.GetBytes(m_fieldName); + } + else + { + value = reader.Get(m_fieldName); + } if (value is DBNull) { @@ -130,51 +128,51 @@ namespace TribalMedia.Framework.Data } } - public class RowMapperField : FieldMapper - where TRowMapper : RowMapper - { - private readonly RowMapperGetAccessor m_fieldGetAccessor; - private readonly RowMapperSetAccessor m_fieldSetAccessor; + //public class RowMapperField : FieldMapper + // where TRowMapper : RowMapper + //{ + // private readonly RowMapperGetAccessor m_fieldGetAccessor; + // private readonly RowMapperSetAccessor m_fieldSetAccessor; - public override object GetParamValue(object obj) - { - return m_fieldGetAccessor((TRowMapper) obj); - } + // public override object GetParamValue(object obj) + // { + // return m_fieldGetAccessor((TRowMapper) obj); + // } - public override void SetPropertyFromReader(object mapper, DataReader reader) - { - object value; + // public override void SetPropertyFromReader(object mapper, DataReader reader) + // { + // object value; - value = GetValue(reader); + // value = GetValue(reader); - if (value == null) - { - m_fieldSetAccessor((TRowMapper) mapper, default(TField)); - } - else - { - m_fieldSetAccessor((TRowMapper) mapper, (TField) value); - } - } + // if (value == null) + // { + // m_fieldSetAccessor((TRowMapper) mapper, default(TField)); + // } + // else + // { + // m_fieldSetAccessor((TRowMapper) mapper, (TField) value); + // } + // } - public RowMapperField(TableMapper tableMapper, string fieldName, RowMapperGetAccessor rowMapperGetAccessor, - RowMapperSetAccessor rowMapperSetAccessor) - : base(tableMapper, fieldName, typeof(TField)) - { - m_fieldGetAccessor = rowMapperGetAccessor; - m_fieldSetAccessor = rowMapperSetAccessor; - } - } + // public RowMapperField(TableMapper tableMapper, string fieldName, RowMapperGetAccessor rowMapperGetAccessor, + // RowMapperSetAccessor rowMapperSetAccessor) + // : base(tableMapper, fieldName, typeof(TField)) + // { + // m_fieldGetAccessor = rowMapperGetAccessor; + // m_fieldSetAccessor = rowMapperSetAccessor; + // } + //} - public class ObjectField : FieldMapper + public class ObjectField : BaseFieldMapper { private readonly ObjectGetAccessor m_fieldGetAccessor; private readonly ObjectSetAccessor m_fieldSetAccessor; public override object GetParamValue(object obj) { - return m_fieldGetAccessor((TObject) obj); + return m_fieldGetAccessor((TObject)obj); } public override void SetPropertyFromReader(object obj, DataReader reader) @@ -185,18 +183,18 @@ namespace TribalMedia.Framework.Data if (value == null) { - m_fieldSetAccessor((TObject) obj, default(TField)); + m_fieldSetAccessor((TObject)obj, default(TField)); } else { - m_fieldSetAccessor((TObject) obj, (TField) value); + m_fieldSetAccessor((TObject)obj, (TField)value); } } - public ObjectField(TableMapper tableMapper, string fieldName, ObjectGetAccessor rowMapperGetAccessor, + public ObjectField(BaseTableMapper tableMapper, string fieldName, ObjectGetAccessor rowMapperGetAccessor, ObjectSetAccessor rowMapperSetAccessor) - : base(tableMapper, fieldName, typeof (TField)) + : base(tableMapper, fieldName, typeof(TField)) { m_fieldGetAccessor = rowMapperGetAccessor; m_fieldSetAccessor = rowMapperSetAccessor; diff --git a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/RowMapper.cs b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseRowMapper.cs similarity index 94% rename from ThirdParty/TribalMedia/TribalMedia.Framework.Data/RowMapper.cs rename to ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseRowMapper.cs index 2771ec921c..2ab8daf6dc 100644 --- a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/RowMapper.cs +++ b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseRowMapper.cs @@ -51,7 +51,7 @@ namespace TribalMedia.Framework.Data public override void FillObject(DataReader reader) { - foreach (FieldMapper fieldMapper in m_schema.Fields.Values) + foreach (BaseFieldMapper fieldMapper in m_schema.Fields.Values) { fieldMapper.SetPropertyFromReader(m_obj, reader); } @@ -76,7 +76,7 @@ namespace TribalMedia.Framework.Data public override void FillObject(DataReader reader) { - foreach (FieldMapper fieldMapper in m_schema.Fields.Values) + foreach (BaseFieldMapper fieldMapper in m_schema.Fields.Values) { fieldMapper.SetPropertyFromReader(this, reader); } diff --git a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/Schema.cs b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseSchema.cs similarity index 63% rename from ThirdParty/TribalMedia/TribalMedia.Framework.Data/Schema.cs rename to ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseSchema.cs index c6bf5d0830..fc59f3b0d5 100644 --- a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/Schema.cs +++ b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseSchema.cs @@ -31,24 +31,25 @@ namespace TribalMedia.Framework.Data { public class Schema { - protected TableMapper m_tableMapper; - protected Dictionary m_mappings; + protected BaseTableMapper m_tableMapper; + protected Dictionary m_mappings; - public Dictionary Fields + public Dictionary Fields { get { return m_mappings; } } - public Schema(TableMapper tableMapper) + public Schema(BaseTableMapper tableMapper) { - m_mappings = new Dictionary(); + m_mappings = new Dictionary(); m_tableMapper = tableMapper; } } public class ObjectSchema : Schema { - public ObjectSchema(TableMapper tableMapper) : base(tableMapper) + public ObjectSchema(BaseTableMapper tableMapper) + : base(tableMapper) { } @@ -65,25 +66,25 @@ namespace TribalMedia.Framework.Data } } - public class RowMapperSchema : Schema - where TRowMapper : RowMapper - { - public RowMapperSchema(TableMapper tableMapper) : base(tableMapper) - { - } + //public class RowMapperSchema : Schema + // where TRowMapper : RowMapper + //{ + // public RowMapperSchema(TableMapper tableMapper) : base(tableMapper) + // { + // } - public RowMapperField AddMapping(string fieldName, - RowMapperGetAccessor - rowMapperGetAccessor, - RowMapperSetAccessor - rowMapperSetAccessor) - { - RowMapperField rowMapperField = - new RowMapperField(m_tableMapper, fieldName, rowMapperGetAccessor, rowMapperSetAccessor); + // public RowMapperField AddMapping(string fieldName, + // RowMapperGetAccessor + // rowMapperGetAccessor, + // RowMapperSetAccessor + // rowMapperSetAccessor) + // { + // RowMapperField rowMapperField = + // new RowMapperField(m_tableMapper, fieldName, rowMapperGetAccessor, rowMapperSetAccessor); - m_mappings.Add(fieldName, rowMapperField); + // m_mappings.Add(fieldName, rowMapperField); - return rowMapperField; - } - } + // return rowMapperField; + // } + //} } \ No newline at end of file diff --git a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/ObjectTableMapper.cs b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseTableMapper.cs similarity index 67% rename from ThirdParty/TribalMedia/TribalMedia.Framework.Data/ObjectTableMapper.cs rename to ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseTableMapper.cs index f2ee4f8395..e4fe0fdd8d 100644 --- a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/ObjectTableMapper.cs +++ b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseTableMapper.cs @@ -27,12 +27,98 @@ using System; using System.Data; using System.Data.Common; +using TribalMedia.Framework.Data; namespace TribalMedia.Framework.Data { - public abstract class ObjectTableMapper : TableMapper + public abstract class BaseTableMapper { - public ObjectTableMapper(DatabaseMapper database, string tableName) + private readonly BaseDatabaseConnector m_database; + private readonly object m_syncRoot = new object(); + + protected void WithConnection(Action action) + { + lock (m_syncRoot) + { + DbConnection m_connection = m_database.GetNewConnection(); + + if (m_connection.State != ConnectionState.Open) + { + m_connection.Open(); + } + + action(m_connection); + + if (m_connection.State == ConnectionState.Open) + { + m_connection.Close(); + } + } + } + + private readonly string m_tableName; + public string TableName + { + get { return m_tableName; } + } + + protected Schema m_schema; + public Schema Schema + { + get { return m_schema; } + } + + protected BaseFieldMapper m_keyFieldMapper; + public BaseFieldMapper KeyFieldMapper + { + get { return m_keyFieldMapper; } + } + + public BaseTableMapper(BaseDatabaseConnector database, string tableName) + { + m_database = database; + m_tableName = tableName.ToLower(); // Stupid MySQL hack. + } + + public string CreateParamName(string fieldName) + { + return m_database.CreateParamName(fieldName); + } + + protected DbCommand CreateSelectCommand(DbConnection connection, string fieldName, object primaryKey) + { + return m_database.CreateSelectCommand(this, connection, fieldName, primaryKey); + } + + public string CreateCondition(DbCommand command, string fieldName, object key) + { + return m_database.CreateCondition(this, command, fieldName, key); + } + + public DbCommand CreateInsertCommand(DbConnection connection, object obj) + { + return m_database.CreateInsertCommand(this, connection, obj); + } + + public DbCommand CreateUpdateCommand(DbConnection connection, object rowMapper, object primaryKey) + { + return m_database.CreateUpdateCommand(this, connection, rowMapper, primaryKey); + } + + public object ConvertToDbType(object value) + { + return m_database.ConvertToDbType(value); + } + + protected virtual DataReader CreateReader(IDataReader reader) + { + return new DataReader(reader); + } + } + + public abstract class BaseTableMapper : BaseTableMapper + { + public BaseTableMapper(BaseDatabaseConnector database, string tableName) : base(database, tableName) { } @@ -52,7 +138,7 @@ namespace TribalMedia.Framework.Data { if (reader.Read()) { - result = FromReader( CreateReader(reader)); + result = FromReader(CreateReader(reader)); success = true; } else @@ -67,7 +153,7 @@ namespace TribalMedia.Framework.Data return success; } - + public virtual bool Remove(TPrimaryKey id) { int deleted = 0; diff --git a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/TableMapper.cs b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/TableMapper.cs deleted file mode 100644 index a2b0aa13d6..0000000000 --- a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/TableMapper.cs +++ /dev/null @@ -1,118 +0,0 @@ -/* -* Copyright (c) Tribal Media AB, http://tribalmedia.se/ -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * The name of Tribal Media AB may not be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ - -using System; -using System.Data; -using System.Data.Common; -using TribalMedia.Framework.Data; - -namespace TribalMedia.Framework.Data -{ - public abstract class TableMapper - { - private readonly DatabaseMapper m_database; - private readonly object m_syncRoot = new object(); - - protected void WithConnection(Action action) - { - lock (m_syncRoot) - { - DbConnection m_connection = m_database.GetNewConnection(); - - if (m_connection.State != ConnectionState.Open) - { - m_connection.Open(); - } - - action(m_connection); - - if (m_connection.State == ConnectionState.Open) - { - m_connection.Close(); - } - } - } - - private readonly string m_tableName; - public string TableName - { - get { return m_tableName; } - } - - protected Schema m_schema; - public Schema Schema - { - get { return m_schema; } - } - - protected FieldMapper m_keyFieldMapper; - public FieldMapper KeyFieldMapper - { - get { return m_keyFieldMapper; } - } - - public TableMapper(DatabaseMapper database, string tableName) - { - m_database = database; - m_tableName = tableName.ToLower(); // Stupid MySQL hack. - } - - public string CreateParamName(string fieldName) - { - return m_database.CreateParamName(fieldName); - } - - protected DbCommand CreateSelectCommand(DbConnection connection, string fieldName, object primaryKey) - { - return m_database.CreateSelectCommand(this, connection, fieldName, primaryKey); - } - - public string CreateCondition(DbCommand command, string fieldName, object key) - { - return m_database.CreateCondition(this, command, fieldName, key); - } - - public DbCommand CreateInsertCommand(DbConnection connection, object obj) - { - return m_database.CreateInsertCommand(this, connection, obj); - } - - public DbCommand CreateUpdateCommand(DbConnection connection, object rowMapper, object primaryKey) - { - return m_database.CreateUpdateCommand(this, connection, rowMapper, primaryKey); - } - - public object ConvertToDbType(object value) - { - return m_database.ConvertToDbType(value); - } - - protected virtual DataReader CreateReader(IDataReader reader) - { - return new DataReader(reader); - } - } -} \ No newline at end of file diff --git a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/TribalMedia.Framework.Data.snk b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/TribalMedia.Framework.Data.snk new file mode 100644 index 0000000000000000000000000000000000000000..fc71027d5e785f0858edf0f9f272b4545a99be7d GIT binary patch literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50096?msn_s3EHSc#ZJC7|3?&p!QfDl3n{nT zX44ZCsEJ`SF<)LsDs#GHjd$qVWV(KCh}r5Akvb^Vc1GPgvgFrqz>VM(5;O(8;w+e^ z1)5*V^kFGEStu!jQ4GB{VBI`<7MY#jU(^^E-B#%vF@y{6rsUo=|EUm?N~oQK>ky_n z^uJaT;`Wehb(*k>pLv`9B?I`-&r}D`26P{mK*YxDCtu11EE7c!zOeSMhkn;D!ZQ~5 z#j;=#P_P4jTfNw$&(=QbHsi16+?)hgjFJ1I7eFouN%0NMOw!0WuBa$o)^;f%*Iscy zHFk+ovQkZ;qD7PL1VL*AqO~!+x+TQ9)7VLV$UjyYJHlTNtDu^iPR)xDmgK9G!XDA9 zalZe;!SYfdaVtJ567`?hQyTb#E|&Cy-To41=dk?@;Psxlh_FC^bPB0z*M##v?o;$I4(q{ZHJc(6t(MX+;3>%~)Z zpZ33s^61Z0L=2qxyU$I+Yk*40inWxp)%;hGAdAn&1Hd}h$%S?F(ZbCyVw?J%!{LyY zGhg#MHzP$6!2N(MjbK646O{qK2pbcaMAa}s2vwrrN