aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ThirdParty/TribalMedia/TribalMedia.Framework.Data/FieldMapper.cs
diff options
context:
space:
mode:
authorlbsa712008-01-14 22:34:19 +0000
committerlbsa712008-01-14 22:34:19 +0000
commit6d751411b7f996c486052c8cbbdbe1e186cebd9f (patch)
treeeb7a0a101695e85cefb3a8f0ed540d402caedc63 /ThirdParty/TribalMedia/TribalMedia.Framework.Data/FieldMapper.cs
parentmy Exists check was slow and wrong. This fixes issues people (diff)
downloadopensim-SC_OLD-6d751411b7f996c486052c8cbbdbe1e186cebd9f.zip
opensim-SC_OLD-6d751411b7f996c486052c8cbbdbe1e186cebd9f.tar.gz
opensim-SC_OLD-6d751411b7f996c486052c8cbbdbe1e186cebd9f.tar.bz2
opensim-SC_OLD-6d751411b7f996c486052c8cbbdbe1e186cebd9f.tar.xz
* Added specialization of DatabaseMapper, DataReader and ObjectFieldMapper to support LLVector3, LLQuaternion and LLUUID
* Added PrimitiveBaseShapeTableMapper to show how it's done NOTE: Nothing actually works yet - this code should be considered more of educational value until it's all wired together
Diffstat (limited to 'ThirdParty/TribalMedia/TribalMedia.Framework.Data/FieldMapper.cs')
-rw-r--r--ThirdParty/TribalMedia/TribalMedia.Framework.Data/FieldMapper.cs52
1 files changed, 4 insertions, 48 deletions
diff --git a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/FieldMapper.cs b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/FieldMapper.cs
index a1fafbe..89bc0f0 100644
--- a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/FieldMapper.cs
+++ b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/FieldMapper.cs
@@ -78,52 +78,18 @@ namespace TribalMedia.Framework.Data
78 command.Parameters.Add(param); 78 command.Parameters.Add(param);
79 } 79 }
80 80
81 public void ExpandField<TObj>(TObj obj, DbCommand command, List<string> fieldNames) 81 public virtual void ExpandField<TObj>(TObj obj, DbCommand command, List<string> fieldNames)
82 { 82 {
83 string fieldName = FieldName; 83 string fieldName = FieldName;
84 object value = GetParamValue(obj); 84 object value = GetParamValue(obj);
85 85
86 //if (ValueType == typeof (Vector3)) 86 RawAddParam(command, fieldNames, fieldName, m_tableMapper.ConvertToDbType(value));
87 //{
88 // Vector3 vector = (Vector3) value;
89
90 // RawAddParam(command, fieldNames, fieldName + "X", vector.X);
91 // RawAddParam(command, fieldNames, fieldName + "Y", vector.Y);
92 // RawAddParam(command, fieldNames, fieldName + "Z", vector.Z);
93 //}
94 //else if (ValueType == typeof (Quaternion))
95 //{
96 // Quaternion quaternion = (Quaternion) value;
97
98 // RawAddParam(command, fieldNames, fieldName + "X", quaternion.X);
99 // RawAddParam(command, fieldNames, fieldName + "Y", quaternion.Y);
100 // RawAddParam(command, fieldNames, fieldName + "Z", quaternion.Z);
101 // RawAddParam(command, fieldNames, fieldName + "W", quaternion.W);
102 //}
103 //else
104 //{
105 RawAddParam(command, fieldNames, fieldName, ConvertToDbType(value));
106 //}
107 } 87 }
108 88
109 protected object GetValue(DataReader reader) 89 protected virtual object GetValue(DataReader reader)
110 { 90 {
111 object value; 91 object value;
112 //if (ValueType == typeof (Vector3)) 92
113 //{
114 // value = reader.GetVector(m_fieldName);
115 //}
116 //else if (ValueType == typeof (Quaternion))
117 //{
118 // value = reader.GetQuaternion(m_fieldName);
119 //}
120 //else
121 //if (ValueType == typeof(UID))
122 //{
123 // Guid guid = reader.GetGuid(m_fieldName);
124 // value = new UID(guid);
125 //}
126 //else
127 if (ValueType == typeof(Guid)) 93 if (ValueType == typeof(Guid))
128 { 94 {
129 value = reader.GetGuid(m_fieldName); 95 value = reader.GetGuid(m_fieldName);
@@ -162,16 +128,6 @@ namespace TribalMedia.Framework.Data
162 128
163 return value; 129 return value;
164 } 130 }
165
166 public static object ConvertToDbType(object value)
167 {
168 //if (value is UID)
169 //{
170 // return (value as UID).UUID.ToString();
171 //}
172
173 return value;
174 }
175 } 131 }
176 132
177 public class RowMapperField<TRowMapper, TField> : FieldMapper 133 public class RowMapperField<TRowMapper, TField> : FieldMapper