From d91bc08737c8d1a461d9aa9f0d707924dc443d1e Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Mon, 2 Feb 2009 11:16:41 +0000 Subject: * Removed the unused Data.Base Framework --- OpenSim/Data/Base/BaseDataReader.cs | 205 ------------ OpenSim/Data/Base/BaseDatabaseConnector.cs | 185 ----------- OpenSim/Data/Base/BaseFieldMapper.cs | 214 ------------- OpenSim/Data/Base/BaseRowMapper.cs | 78 ----- OpenSim/Data/Base/BaseSchema.cs | 94 ------ OpenSim/Data/Base/BaseTableMapper.cs | 399 ------------------------ OpenSim/Data/Base/OpenSim.Data.Base.snk | Bin 596 -> 0 bytes OpenSim/Data/Base/Properties/AssemblyInfo.cs | 67 ---- OpenSim/Data/MSSQLMapper/MSSQLDatabaseMapper.cs | 64 ---- OpenSim/Data/MapperFactory/DataMapperFactory.cs | 55 ---- OpenSim/Data/MySQLMapper/MySQLDataReader.cs | 38 --- OpenSim/Data/MySQLMapper/MySQLDatabaseMapper.cs | 58 ---- OpenSim/Data/OpenSimDataReader.cs | 63 ---- OpenSim/Data/OpenSimDatabaseConnector.cs | 55 ---- OpenSim/Data/OpenSimObjectFieldMapper.cs | 100 ------ OpenSim/Data/OpenSimTableMapper.cs | 38 --- OpenSim/Data/PrimitiveBaseShapeTableMapper.cs | 170 ---------- 17 files changed, 1883 deletions(-) delete mode 100644 OpenSim/Data/Base/BaseDataReader.cs delete mode 100644 OpenSim/Data/Base/BaseDatabaseConnector.cs delete mode 100644 OpenSim/Data/Base/BaseFieldMapper.cs delete mode 100644 OpenSim/Data/Base/BaseRowMapper.cs delete mode 100644 OpenSim/Data/Base/BaseSchema.cs delete mode 100644 OpenSim/Data/Base/BaseTableMapper.cs delete mode 100644 OpenSim/Data/Base/OpenSim.Data.Base.snk delete mode 100644 OpenSim/Data/Base/Properties/AssemblyInfo.cs delete mode 100644 OpenSim/Data/MSSQLMapper/MSSQLDatabaseMapper.cs delete mode 100644 OpenSim/Data/MapperFactory/DataMapperFactory.cs delete mode 100644 OpenSim/Data/MySQLMapper/MySQLDataReader.cs delete mode 100644 OpenSim/Data/MySQLMapper/MySQLDatabaseMapper.cs delete mode 100644 OpenSim/Data/OpenSimDataReader.cs delete mode 100644 OpenSim/Data/OpenSimDatabaseConnector.cs delete mode 100644 OpenSim/Data/OpenSimObjectFieldMapper.cs delete mode 100644 OpenSim/Data/OpenSimTableMapper.cs delete mode 100644 OpenSim/Data/PrimitiveBaseShapeTableMapper.cs (limited to 'OpenSim') diff --git a/OpenSim/Data/Base/BaseDataReader.cs b/OpenSim/Data/Base/BaseDataReader.cs deleted file mode 100644 index 23f03e5..0000000 --- a/OpenSim/Data/Base/BaseDataReader.cs +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may 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.IO; - -namespace OpenSim.Data.Base -{ - /// - /// - /// - public abstract class BaseDataReader - { - private readonly IDataReader m_source; - - /// - /// - /// - /// - public BaseDataReader(IDataReader source) - { - m_source = source; - } - - /// - /// - /// - /// - /// - public object Get(string name) - { - return m_source[name]; - } - - /// - /// - /// - /// - /// - public ushort GetUShort(string 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); - return value; - } - - /// - /// - /// - /// - /// - public sbyte GetSByte(string name) - { - return (sbyte)m_source.GetInt16(m_source.GetOrdinal(name)); - } - - /// - /// - /// - /// - /// - public float GetFloat(string name) - { - return m_source.GetFloat(m_source.GetOrdinal(name)); - } - - /// - /// - /// - /// - /// - public byte[] GetBytes(string name) - { - int ordinal = m_source.GetOrdinal(name); - - if (m_source.GetValue(ordinal) == DBNull.Value) - { - return null; - } - - byte[] buffer = new byte[16384]; - - MemoryStream memStream = new MemoryStream(); - - long totalRead = 0; - - int bytesRead; - do - { - bytesRead = (int)m_source.GetBytes(ordinal, totalRead, buffer, 0, buffer.Length); - totalRead += bytesRead; - - memStream.Write(buffer, 0, bytesRead); - } while (bytesRead == buffer.Length); - - return memStream.ToArray(); - } - - /// - /// - /// - /// - /// - public string GetString(string name) - { - int ordinal = m_source.GetOrdinal(name); - object value = m_source.GetValue(ordinal); - - if (value is DBNull) - { - return null; - } - - return (string)value; - } - - /// - /// - /// - /// - public bool Read() - { - return m_source.Read(); - } - - /// - /// - /// - /// - /// - public virtual Guid GetGuid(string name) - { - return m_source.GetGuid(m_source.GetOrdinal(name)); - } - - /// - /// - /// - /// - /// - public UInt32 GetUInt32(string name) - { - return (UInt32)GetInt32(name); - } - - /// - /// - /// - /// - /// - private Int32 GetInt32(string name) - { - int ordinal = m_source.GetOrdinal(name); - int int32 = m_source.GetInt32(ordinal); - return int32; - } - - /// - /// - /// - /// - /// - public Int64 GetInt64(string name) - { - int ordinal = m_source.GetOrdinal(name); - long int64 = m_source.GetInt64(ordinal); - return int64; - } - } -} diff --git a/OpenSim/Data/Base/BaseDatabaseConnector.cs b/OpenSim/Data/Base/BaseDatabaseConnector.cs deleted file mode 100644 index 542004c..0000000 --- a/OpenSim/Data/Base/BaseDatabaseConnector.cs +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may 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.Collections.Generic; -using System.Data; -using System.Data.Common; - -namespace OpenSim.Data.Base -{ - /// - /// - /// - public abstract class BaseDatabaseConnector - { - protected string m_connectionString; - - /// - /// - /// - /// - public BaseDatabaseConnector(string connectionString) - { - m_connectionString = connectionString; - } - - public abstract DbConnection GetNewConnection(); - public abstract string CreateParamName(string fieldName); - - /// - /// - /// - /// - /// - /// - /// - /// - public DbCommand CreateSelectCommand(BaseTableMapper mapper, DbConnection connection, string fieldName, object key) - { - string table = mapper.TableName; - - DbCommand command = connection.CreateCommand(); - - string conditionString = CreateCondition(mapper, command, fieldName, key); - - string query = - String.Format("select * from {0} where {1}", table, conditionString); - - command.CommandText = query; - command.CommandType = CommandType.Text; - - return command; - } - - /// - /// - /// - /// - /// - /// - /// - /// - public string CreateCondition(BaseTableMapper mapper, DbCommand command, string fieldName, object key) - { - string keyFieldParamName = mapper.CreateParamName(fieldName); - - DbParameter param = command.CreateParameter(); - param.ParameterName = keyFieldParamName; - param.Value = ConvertToDbType(key); - command.Parameters.Add(param); - - return String.Format("{0}={1}", fieldName, keyFieldParamName); - } - - /// - /// - /// - /// - /// - /// - /// - /// - public DbCommand CreateUpdateCommand(BaseTableMapper mapper, DbConnection connection, object rowMapper, object primaryKey) - { - string table = mapper.TableName; - - List fieldNames = new List(); - - DbCommand command = connection.CreateCommand(); - - foreach (BaseFieldMapper fieldMapper in mapper.Schema.Fields.Values) - { - if (fieldMapper != mapper.KeyFieldMapper) - { - fieldMapper.ExpandField(rowMapper, command, fieldNames); - } - } - - List assignments = new List(); - - foreach (string field in fieldNames) - { - assignments.Add(String.Format("{0}={1}", field, mapper.CreateParamName(field))); - } - - string conditionString = mapper.CreateCondition(command, mapper.KeyFieldMapper.FieldName, primaryKey); - - command.CommandText = - String.Format("update {0} set {1} where {2}", table, String.Join(", ", assignments.ToArray()), - conditionString); - - return command; - } - - /// - /// - /// - /// - /// - /// - /// - public DbCommand CreateInsertCommand(BaseTableMapper mapper, DbConnection connection, object obj) - { - string table = mapper.TableName; - - List fieldNames = new List(); - - DbCommand command = connection.CreateCommand(); - - foreach (BaseFieldMapper fieldMapper in mapper.Schema.Fields.Values) - { - fieldMapper.ExpandField(obj, command, fieldNames); - } - - List paramNames = new List(); - - foreach (string field in fieldNames) - { - paramNames.Add(mapper.CreateParamName(field)); - } - - command.CommandText = - String.Format("insert into {0} ({1}) values ({2})", table, String.Join(", ", fieldNames.ToArray()), - String.Join(", ", paramNames.ToArray())); - - return command; - } - - /// - /// - /// - /// - /// - public virtual object ConvertToDbType(object value) - { - return value; - } - - public abstract BaseDataReader CreateReader(IDataReader reader); - } -} diff --git a/OpenSim/Data/Base/BaseFieldMapper.cs b/OpenSim/Data/Base/BaseFieldMapper.cs deleted file mode 100644 index c7d6bc9..0000000 --- a/OpenSim/Data/Base/BaseFieldMapper.cs +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may 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.Collections.Generic; -using System.Data.Common; - -namespace OpenSim.Data.Base -{ - public delegate TField ObjectGetAccessor(TObj obj); - public delegate void ObjectSetAccessor(TObj obj, TField value); - - /// - /// - /// - public abstract class BaseFieldMapper - { - private readonly BaseTableMapper m_tableMapper; - private readonly string m_fieldName; - - /// - /// - /// - public string FieldName - { - get { return m_fieldName; } - } - - protected Type m_valueType; - - /// - /// - /// - public Type ValueType - { - get { return m_valueType; } - } - - public abstract object GetParamValue(object obj); - - /// - /// - /// - /// - /// - /// - public BaseFieldMapper(BaseTableMapper tableMapper, string fieldName, Type valueType) - { - m_fieldName = fieldName; - m_valueType = valueType; - m_tableMapper = tableMapper; - } - - public abstract void SetPropertyFromReader(object mapper, BaseDataReader reader); - - /// - /// - /// - /// - /// - /// - /// - public void RawAddParam(DbCommand command, List fieldNames, string fieldName, object value) - { - string paramName = m_tableMapper.CreateParamName(fieldName); - fieldNames.Add(fieldName); - - DbParameter param = command.CreateParameter(); - param.ParameterName = paramName; - param.Value = value; - - command.Parameters.Add(param); - } - - /// - /// - /// - /// - /// - /// - /// - public virtual void ExpandField(TObj obj, DbCommand command, List fieldNames) - { - string fieldName = FieldName; - object value = GetParamValue(obj); - - RawAddParam(command, fieldNames, fieldName, m_tableMapper.ConvertToDbType(value)); - } - - /// - /// - /// - /// - /// - protected virtual object GetValue(BaseDataReader reader) - { - object value; - - if (ValueType == typeof(Guid)) - { - value = reader.GetGuid(m_fieldName); - } - 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(uint)) - { - value = reader.GetUInt32(m_fieldName); - } - else if (ValueType == typeof(byte[])) - { - value = reader.GetBytes(m_fieldName); - } - else - { - value = reader.Get(m_fieldName); - } - - if (value is DBNull) - { - value = default(ValueType); - } - - return value; - } - } - - /// - /// - /// - /// - /// - 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); - } - - public override void SetPropertyFromReader(object obj, BaseDataReader reader) - { - object value; - - value = GetValue(reader); - - if (value == null) - { - m_fieldSetAccessor((TObject)obj, default(TField)); - } - else - { - m_fieldSetAccessor((TObject)obj, (TField)value); - } - } - - - /// - /// - /// - /// - /// - /// - /// - public ObjectField(BaseTableMapper tableMapper, string fieldName, ObjectGetAccessor rowMapperGetAccessor, - ObjectSetAccessor rowMapperSetAccessor) - : base(tableMapper, fieldName, typeof(TField)) - { - m_fieldGetAccessor = rowMapperGetAccessor; - m_fieldSetAccessor = rowMapperSetAccessor; - } - } -} diff --git a/OpenSim/Data/Base/BaseRowMapper.cs b/OpenSim/Data/Base/BaseRowMapper.cs deleted file mode 100644 index d0e545b..0000000 --- a/OpenSim/Data/Base/BaseRowMapper.cs +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may 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. - */ - -namespace OpenSim.Data.Base -{ - /// - /// - /// - public abstract class BaseRowMapper - { - public abstract void FiPrimitive(BaseDataReader reader); - } - - /// - /// - /// - /// - public class BaseRowMapper : BaseRowMapper - { - private readonly BaseSchema m_schema; - private readonly TObj m_obj; - - /// - /// - /// - public TObj Object - { - get { return m_obj; } - } - - /// - /// - /// - /// - /// - public BaseRowMapper(BaseSchema schema, TObj obj) - { - m_schema = schema; - m_obj = obj; - } - - /// - /// - /// - /// - public override void FiPrimitive(BaseDataReader reader) - { - foreach (BaseFieldMapper fieldMapper in m_schema.Fields.Values) - { - fieldMapper.SetPropertyFromReader(this, reader); - } - } - } -} diff --git a/OpenSim/Data/Base/BaseSchema.cs b/OpenSim/Data/Base/BaseSchema.cs deleted file mode 100644 index 9d69a40..0000000 --- a/OpenSim/Data/Base/BaseSchema.cs +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may 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.Collections.Generic; - -namespace OpenSim.Data.Base -{ - /// - /// - /// - public class BaseSchema - { - protected BaseTableMapper m_tableMapper; - protected Dictionary m_mappings; - - /// - /// - /// - public Dictionary Fields - { - get { return m_mappings; } - } - - /// - /// - /// - /// - public BaseSchema(BaseTableMapper tableMapper) - { - m_mappings = new Dictionary(); - m_tableMapper = tableMapper; - } - } - - /// - /// - /// - /// - public class BaseSchema : BaseSchema - { - /// - /// - /// - /// - public BaseSchema(BaseTableMapper tableMapper) - : base(tableMapper) - { - } - - /// - /// - /// - /// - /// - /// - /// - /// - public ObjectField AddMapping(string fieldName, - ObjectGetAccessor rowMapperGetAccessor, - ObjectSetAccessor rowMapperSetAccessor) - { - ObjectField rowMapperField = - new ObjectField(m_tableMapper, fieldName, rowMapperGetAccessor, rowMapperSetAccessor); - - m_mappings.Add(fieldName, rowMapperField); - - return rowMapperField; - } - } -} diff --git a/OpenSim/Data/Base/BaseTableMapper.cs b/OpenSim/Data/Base/BaseTableMapper.cs deleted file mode 100644 index 28b7ac8..0000000 --- a/OpenSim/Data/Base/BaseTableMapper.cs +++ /dev/null @@ -1,399 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may 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; - -namespace OpenSim.Data.Base -{ - /// - /// - /// - public abstract class BaseTableMapper - { - 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 BaseSchema m_schema; - public BaseSchema 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 BaseDataReader CreateReader(IDataReader reader) - { - return m_database.CreateReader(reader); - } - } - - /// - /// - /// - /// - /// - public abstract class BaseTableMapper : BaseTableMapper - { - /// - /// - /// - /// - /// - public BaseTableMapper(BaseDatabaseConnector database, string tableName) - : base(database, tableName) - { - } - - - - /// - /// HACK: This is a temporary function used by TryGetValue(). - /// Due to a bug in mono 1.2.6, delegate blocks cannot contain - /// a using block. This has been fixed in SVN, so the next - /// mono release should work. - /// - /// - /// - /// - /// - private void TryGetConnectionValue(DbConnection connection, TPrimaryKey primaryKey, ref TRowMapper result, ref bool success) - { - using ( - DbCommand command = - CreateSelectCommand(connection, KeyFieldMapper.FieldName, primaryKey)) - { - using (IDataReader reader = command.ExecuteReader()) - { - if (reader.Read()) - { - result = FromReader(CreateReader(reader)); - success = true; - } - else - { - success = false; - } - } - } - } - - /// - /// - /// - /// - /// - /// - public bool TryGetValue(TPrimaryKey primaryKey, out TRowMapper value) - { - TRowMapper result = default(TRowMapper); - bool success = false; - - WithConnection(delegate(DbConnection connection) - { - TryGetConnectionValue(connection, primaryKey, ref result, ref success); - }); - - value = result; - - return success; - } - - /// - /// HACK: This is a temporary function used by Remove(). - /// Due to a bug in mono 1.2.6, delegate blocks cannot contain - /// a using block. This has been fixed in SVN, so the next - /// mono release should work. - /// - /// - /// - /// - protected virtual void TryDelete(DbConnection connection, TPrimaryKey id, ref int deleted) - { - using ( - DbCommand command = - CreateDeleteCommand(connection, KeyFieldMapper.FieldName, id)) - { - deleted = command.ExecuteNonQuery(); - } - } - - /// - /// - /// - /// - /// - public virtual bool Remove(TPrimaryKey id) - { - int deleted = 0; - - WithConnection(delegate(DbConnection connection) - { - TryDelete(connection, id, ref deleted); - }); - - if (deleted == 1) - { - return true; - } - else - { - return false; - } - } - - /// - /// - /// - /// - /// - /// - /// - public DbCommand CreateDeleteCommand(DbConnection connection, string fieldName, TPrimaryKey primaryKey) - { - string table = TableName; - - DbCommand command = connection.CreateCommand(); - - string conditionString = CreateCondition(command, fieldName, primaryKey); - - string query = - String.Format("delete from {0} where {1}", table, conditionString); - - command.CommandText = query; - command.CommandType = CommandType.Text; - - return command; - } - - - - /// - /// HACK: This is a temporary function used by Update(). - /// Due to a bug in mono 1.2.6, delegate blocks cannot contain - /// a using block. This has been fixed in SVN, so the next - /// mono release should work. - /// - /// - /// - /// - /// - protected void TryUpdate(DbConnection connection, TPrimaryKey primaryKey, TRowMapper value, ref int updated) - { - using (DbCommand command = CreateUpdateCommand(connection, value, primaryKey)) - { - updated = command.ExecuteNonQuery(); - } - } - - /// - /// - /// - /// - /// - /// - public virtual bool Update(TPrimaryKey primaryKey, TRowMapper value) - { - int updated = 0; - - WithConnection(delegate(DbConnection connection) - { - TryUpdate(connection, primaryKey, value, ref updated); - }); - - if (updated == 1) - { - return true; - } - else - { - return false; - } - } - - /// - /// HACK: This is a temporary function used by Add(). - /// Due to a bug in mono 1.2.6, delegate blocks cannot contain - /// a using block. This has been fixed in SVN, so the next - /// mono release should work. - /// - /// - /// - /// - protected void TryAdd(DbConnection connection, TRowMapper value, ref int added) - { - using (DbCommand command = CreateInsertCommand(connection, value)) - { - added = command.ExecuteNonQuery(); - } - } - - /// - /// - /// - /// - /// - public virtual bool Add(TRowMapper value) - { - int added = 0; - - WithConnection(delegate(DbConnection connection) - { - TryAdd(connection, value, ref added); - }); - - if (added == 1) - { - return true; - } - else - { - return false; - } - } - - public abstract TRowMapper FromReader(BaseDataReader reader); - } -} diff --git a/OpenSim/Data/Base/OpenSim.Data.Base.snk b/OpenSim/Data/Base/OpenSim.Data.Base.snk deleted file mode 100644 index fc71027..0000000 Binary files a/OpenSim/Data/Base/OpenSim.Data.Base.snk and /dev/null differ diff --git a/OpenSim/Data/Base/Properties/AssemblyInfo.cs b/OpenSim/Data/Base/Properties/AssemblyInfo.cs deleted file mode 100644 index f165434..0000000 --- a/OpenSim/Data/Base/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may 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.Reflection; -using System.Runtime.InteropServices; -using System.Security; - -// General information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly : AssemblyTitle("OpenSim.Data.Base")] -[assembly : AssemblyDescription("Generic Database Abstraction Layer")] -[assembly : AssemblyConfiguration("")] -[assembly : AssemblyCompany("OpenSim Project (www.opensimulator.org)")] -[assembly: AssemblyProduct("OpenSim.Data.Base")] -[assembly: AssemblyCopyright("Copyright (c) 2007 OpenSim Project (www.opensimulator.org)")] -[assembly : AssemblyTrademark("")] -[assembly : AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. - -[assembly : ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM - -[assembly : Guid("9269f421-19d9-4eea-bfe3-c0ffe426fada")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: - -[assembly : AssemblyVersion("1.0.0.0")] -[assembly : AssemblyFileVersion("1.0.0.0")] -[assembly : AllowPartiallyTrustedCallers] diff --git a/OpenSim/Data/MSSQLMapper/MSSQLDatabaseMapper.cs b/OpenSim/Data/MSSQLMapper/MSSQLDatabaseMapper.cs deleted file mode 100644 index bd683f3..0000000 --- a/OpenSim/Data/MSSQLMapper/MSSQLDatabaseMapper.cs +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may 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.Common; -using System.Data.SqlClient; - -namespace OpenSim.Data.MSSQLMapper -{ - public class MSSQLDatabaseMapper : OpenSimDatabaseConnector - { - public MSSQLDatabaseMapper(string connectionString) - : base(connectionString) - { - } - - public override DbConnection GetNewConnection() - { - SqlConnection connection = new SqlConnection(m_connectionString); - return connection; - } - - public override object ConvertToDbType(object value) - { - if (value is UInt32) - { - UInt32 tmpVal = (UInt32) value; - Int64 result = Convert.ToInt64(tmpVal); - return result; - } - - return base.ConvertToDbType(value); - } - - public override string CreateParamName(string fieldName) - { - return "@" + fieldName; - } - } -} \ No newline at end of file diff --git a/OpenSim/Data/MapperFactory/DataMapperFactory.cs b/OpenSim/Data/MapperFactory/DataMapperFactory.cs deleted file mode 100644 index 0b1fadd..0000000 --- a/OpenSim/Data/MapperFactory/DataMapperFactory.cs +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may 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 OpenSim.Data.Base; -using OpenSim.Data.MSSQLMapper; -using OpenSim.Data.MySQLMapper; - -namespace OpenSim.Data.MapperFactory -{ - public class DataMapperFactory - { - public enum MAPPER_TYPE { - MySQL, - MSSQL, - }; - - static public BaseDatabaseConnector GetDataBaseMapper(MAPPER_TYPE type, string connectionString) - { - switch (type) - { - case MAPPER_TYPE.MySQL: - return new MySQLDatabaseMapper(connectionString); - case MAPPER_TYPE.MSSQL: - return new MSSQLDatabaseMapper(connectionString); - default: - throw new ArgumentException("Unknown Database Mapper type [" + type + "]."); - } - } - } -} diff --git a/OpenSim/Data/MySQLMapper/MySQLDataReader.cs b/OpenSim/Data/MySQLMapper/MySQLDataReader.cs deleted file mode 100644 index 9b5de2a..0000000 --- a/OpenSim/Data/MySQLMapper/MySQLDataReader.cs +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may 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.Data; - -namespace OpenSim.Data.MySQLMapper -{ - public class MySQLDataReader : OpenSimDataReader - { - public MySQLDataReader(IDataReader source) : base(source) - { - } - } -} diff --git a/OpenSim/Data/MySQLMapper/MySQLDatabaseMapper.cs b/OpenSim/Data/MySQLMapper/MySQLDatabaseMapper.cs deleted file mode 100644 index b7940b8..0000000 --- a/OpenSim/Data/MySQLMapper/MySQLDatabaseMapper.cs +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may 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.Data; -using System.Data.Common; -using MySql.Data.MySqlClient; -using OpenSim.Data.Base; - -namespace OpenSim.Data.MySQLMapper -{ - public class MySQLDatabaseMapper : OpenSimDatabaseConnector - { - public MySQLDatabaseMapper(string connectionString) - : base(connectionString) - { - } - - public override DbConnection GetNewConnection() - { - MySqlConnection connection = new MySqlConnection(m_connectionString); - return connection; - } - - public override string CreateParamName(string fieldName) - { - return "?" + fieldName; - } - - public override BaseDataReader CreateReader(IDataReader reader) - { - return new MySQLDataReader(reader); - } - } -} \ No newline at end of file diff --git a/OpenSim/Data/OpenSimDataReader.cs b/OpenSim/Data/OpenSimDataReader.cs deleted file mode 100644 index f584855..0000000 --- a/OpenSim/Data/OpenSimDataReader.cs +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may 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.Data; -using OpenMetaverse; -using OpenSim.Data.Base; - -namespace OpenSim.Data -{ - public class OpenSimDataReader : BaseDataReader - { - public OpenSimDataReader(IDataReader source) : base(source) - { - } - - public Vector3 GetVector(string s) - { - float x = GetFloat(s + "X"); - float y = GetFloat(s + "Y"); - float z = GetFloat(s + "Z"); - - Vector3 vector = new Vector3(x, y, z); - - return vector; - } - - public Quaternion GetQuaternion(string s) - { - float x = GetFloat(s + "X"); - float y = GetFloat(s + "Y"); - float z = GetFloat(s + "Z"); - float w = GetFloat(s + "W"); - - Quaternion quaternion = new Quaternion(x, y, z, w); - - return quaternion; - } - } -} diff --git a/OpenSim/Data/OpenSimDatabaseConnector.cs b/OpenSim/Data/OpenSimDatabaseConnector.cs deleted file mode 100644 index 68a4ee4..0000000 --- a/OpenSim/Data/OpenSimDatabaseConnector.cs +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may 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.Data; -using OpenMetaverse; -using OpenSim.Data.Base; - -namespace OpenSim.Data -{ - public abstract class OpenSimDatabaseConnector : BaseDatabaseConnector - { - public OpenSimDatabaseConnector(string connectionString) : base(connectionString) - { - } - - public override object ConvertToDbType(object value) - { - if (value is UUID) - { - return ((UUID)value).ToString(); - } - - return base.ConvertToDbType(value); - } - - public override BaseDataReader CreateReader(IDataReader reader) - { - return new OpenSimDataReader(reader); - } - } -} diff --git a/OpenSim/Data/OpenSimObjectFieldMapper.cs b/OpenSim/Data/OpenSimObjectFieldMapper.cs deleted file mode 100644 index a342494..0000000 --- a/OpenSim/Data/OpenSimObjectFieldMapper.cs +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may 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.Collections.Generic; -using System.Data.Common; -using OpenMetaverse; -using OpenSim.Data.Base; - -namespace OpenSim.Data -{ - public class OpenSimObjectFieldMapper : ObjectField - { - public OpenSimObjectFieldMapper(BaseTableMapper tableMapper, string fieldName, - ObjectGetAccessor rowMapperGetAccessor, - ObjectSetAccessor rowMapperSetAccessor) - : base(tableMapper, fieldName, rowMapperGetAccessor, rowMapperSetAccessor) - { - } - - public override void ExpandField(TObj obj, DbCommand command, List fieldNames) - { - string fieldName = FieldName; - object value = GetParamValue(obj); - - if (ValueType == typeof(Vector3)) - { - Vector3 vector = (Vector3)value; - - RawAddParam(command, fieldNames, fieldName + "X", vector.X); - RawAddParam(command, fieldNames, fieldName + "Y", vector.Y); - RawAddParam(command, fieldNames, fieldName + "Z", vector.Z); - } - else if (ValueType == typeof(Quaternion)) - { - Quaternion quaternion = (Quaternion)value; - - RawAddParam(command, fieldNames, fieldName + "X", quaternion.X); - RawAddParam(command, fieldNames, fieldName + "Y", quaternion.Y); - RawAddParam(command, fieldNames, fieldName + "Z", quaternion.Z); - RawAddParam(command, fieldNames, fieldName + "W", quaternion.W); - } - else - { - base.ExpandField(obj, command, fieldNames); - } - } - - protected override object GetValue(BaseDataReader reader) - { - object value; - - OpenSimDataReader osreader = (OpenSimDataReader) reader; - - if (ValueType == typeof(Vector3)) - { - value = osreader.GetVector(FieldName); - } - else if (ValueType == typeof(Quaternion)) - { - value = osreader.GetQuaternion(FieldName); - } - else if (ValueType == typeof(UUID)) - { - Guid guid = reader.GetGuid(FieldName); - value = new UUID(guid); - } - else - { - value = base.GetValue(reader); - } - - return value; - } - } -} diff --git a/OpenSim/Data/OpenSimTableMapper.cs b/OpenSim/Data/OpenSimTableMapper.cs deleted file mode 100644 index f09ef7d..0000000 --- a/OpenSim/Data/OpenSimTableMapper.cs +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may 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 OpenSim.Data.Base; - -namespace OpenSim.Data -{ - public abstract class OpenSimTableMapper : BaseTableMapper - { - public OpenSimTableMapper(BaseDatabaseConnector database, string tableName) : base(database, tableName) - { - } - } -} diff --git a/OpenSim/Data/PrimitiveBaseShapeTableMapper.cs b/OpenSim/Data/PrimitiveBaseShapeTableMapper.cs deleted file mode 100644 index 5a6b3db..0000000 --- a/OpenSim/Data/PrimitiveBaseShapeTableMapper.cs +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * 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. - * * Neither the name of the OpenSim Project nor the - * names of its contributors may 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 OpenMetaverse; -using OpenSim.Data.Base; -using OpenSim.Framework; - -namespace OpenSim.Data -{ - public class PrimitiveBaseShapeRowMapper : BaseRowMapper - { - public Guid SceneObjectPartId; - - public PrimitiveBaseShapeRowMapper(BaseSchema schema, PrimitiveBaseShape obj) : base(schema, obj) - { - } - } - - public class PrimitiveBaseShapeTableMapper : OpenSimTableMapper - { - public PrimitiveBaseShapeTableMapper(BaseDatabaseConnector connection, string tableName) - : base(connection, tableName) - { - BaseSchema rowMapperSchema = new BaseSchema(this); - m_schema = rowMapperSchema; - - m_keyFieldMapper = rowMapperSchema.AddMapping("SceneObjectPartId", - delegate(PrimitiveBaseShapeRowMapper shape) { return shape.SceneObjectPartId; }, - delegate(PrimitiveBaseShapeRowMapper shape, Guid value) { shape.SceneObjectPartId = value; }); - - rowMapperSchema.AddMapping("PCode", - delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PCode; }, - delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PCode = value; }); - - rowMapperSchema.AddMapping("PathBegin", - delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathBegin; }, - delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.PathBegin = value; }); - - rowMapperSchema.AddMapping("PathEnd", - delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathEnd; }, - delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.PathEnd = value; }); - - rowMapperSchema.AddMapping("PathScaleX", - delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathScaleX; }, - delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathScaleX = value; }); - - rowMapperSchema.AddMapping("PathScaleY", - delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathScaleY; }, - delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathScaleY = value; }); - - rowMapperSchema.AddMapping("PathShearX", - delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathShearX; }, - delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathShearX = value; }); - - rowMapperSchema.AddMapping("PathShearY", - delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathShearY; }, - delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathShearY = value; }); - - rowMapperSchema.AddMapping("ProfileBegin", - delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ProfileBegin; }, - delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.ProfileBegin = value; }); - - rowMapperSchema.AddMapping("ProfileEnd", - delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ProfileEnd; }, - delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.ProfileEnd = value; }); - - rowMapperSchema.AddMapping("Scale", - delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.Scale; }, - delegate(PrimitiveBaseShapeRowMapper shape, Vector3 value) { shape.Object.Scale = value; }); - - rowMapperSchema.AddMapping("PathTaperX", - delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathTaperX; }, - delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathTaperX = value; }); - - rowMapperSchema.AddMapping("PathTaperY", - delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathTaperY; }, - delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathTaperY = value; }); - - rowMapperSchema.AddMapping("PathTwist", - delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathTwist; }, - delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathTwist = value; }); - - rowMapperSchema.AddMapping("PathRadiusOffset", - delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathRadiusOffset; }, - delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathRadiusOffset = value; }); - - rowMapperSchema.AddMapping("PathRevolutions", - delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathRevolutions; }, - delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathRevolutions = value; }); - - rowMapperSchema.AddMapping("PathTwistBegin", - delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathTwistBegin; }, - delegate(PrimitiveBaseShapeRowMapper shape, sbyte value) { shape.Object.PathTwistBegin = value; }); - - rowMapperSchema.AddMapping("PathCurve", - delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.PathCurve; }, - delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.PathCurve = value; }); - - rowMapperSchema.AddMapping("ProfileCurve", - delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ProfileCurve; }, - delegate(PrimitiveBaseShapeRowMapper shape, byte value) { shape.Object.ProfileCurve = value; }); - - rowMapperSchema.AddMapping("ProfileHollow", - delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ProfileHollow; }, - delegate(PrimitiveBaseShapeRowMapper shape, ushort value) { shape.Object.ProfileHollow = value; }); - - rowMapperSchema.AddMapping("TextureEntry", - delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.TextureEntry; }, - delegate(PrimitiveBaseShapeRowMapper shape, byte[] value) { shape.Object.TextureEntry = value; }); - - rowMapperSchema.AddMapping("ExtraParams", - delegate(PrimitiveBaseShapeRowMapper shape) { return shape.Object.ExtraParams; }, - delegate(PrimitiveBaseShapeRowMapper shape, byte[] value) { shape.Object.ExtraParams = value; }); - } - - public override PrimitiveBaseShapeRowMapper FromReader(BaseDataReader reader) - { - PrimitiveBaseShape shape = new PrimitiveBaseShape(); - - PrimitiveBaseShapeRowMapper mapper = new PrimitiveBaseShapeRowMapper(m_schema, shape); - mapper.FiPrimitive(reader); - - return mapper; - } - - public bool Update(Guid sceneObjectPartId, PrimitiveBaseShape primitiveBaseShape) - { - PrimitiveBaseShapeRowMapper mapper = CreateRowMapper(sceneObjectPartId, primitiveBaseShape); - return Update(sceneObjectPartId, mapper); - } - - public bool Add(Guid sceneObjectPartId, PrimitiveBaseShape primitiveBaseShape) - { - PrimitiveBaseShapeRowMapper mapper = CreateRowMapper(sceneObjectPartId, primitiveBaseShape); - return Add(mapper); - } - - private PrimitiveBaseShapeRowMapper CreateRowMapper(Guid sceneObjectPartId, PrimitiveBaseShape primitiveBaseShape) - { - PrimitiveBaseShapeRowMapper mapper = new PrimitiveBaseShapeRowMapper(m_schema, primitiveBaseShape); - mapper.SceneObjectPartId = sceneObjectPartId; - return mapper; - } - } -} -- cgit v1.1