aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/NHibernate/Types/LLUUIDUserType.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Data/NHibernate/Types/LLUUIDUserType.cs')
-rw-r--r--OpenSim/Data/NHibernate/Types/LLUUIDUserType.cs78
1 files changed, 78 insertions, 0 deletions
diff --git a/OpenSim/Data/NHibernate/Types/LLUUIDUserType.cs b/OpenSim/Data/NHibernate/Types/LLUUIDUserType.cs
new file mode 100644
index 0000000..babc7fd
--- /dev/null
+++ b/OpenSim/Data/NHibernate/Types/LLUUIDUserType.cs
@@ -0,0 +1,78 @@
1using System;
2using System.Data;
3using NHibernate;
4using NHibernate.SqlTypes;
5using NHibernate.UserTypes;
6using libsecondlife;
7
8namespace OpenSim.Data.NHibernate
9{
10 [Serializable]
11 public class LLUUIDUserType: IUserType
12 {
13 public object Assemble(object cached, object owner)
14 {
15 return cached;
16 }
17
18 public bool IUserType.Equals(object uuid1, object uuid2)
19 {
20 return uuid1.Equals(uuid2);
21 }
22
23 public object DeepCopy(object uuid)
24 {
25 return uuid;
26 }
27
28 public object Disassemble(object uuid)
29 {
30 return uuid;
31 }
32
33 public int GetHashCode(object uuid)
34 {
35 return (uuid == null) ? 0 : uuid.GetHashCode();
36 }
37
38 public bool IsMutable
39 {
40 get { return false; }
41 }
42
43 public object NullSafeGet(System.Data.IDataReader rs, string[] names, object owner)
44 {
45 object uuid = null;
46
47 int ord = rs.GetOrdinal(names[0]);
48 if (!rs.IsDBNull(ord))
49 {
50 string first = (string)rs.GetString(ord);
51 uuid = new LLUUID(first);
52 }
53
54 return uuid;
55 }
56
57 public void NullSafeSet(System.Data.IDbCommand cmd, object obj, int index)
58 {
59 LLUUID uuid = (LLUUID)obj;
60 ((IDataParameter)cmd.Parameters[index]).Value = uuid.ToString();
61 }
62
63 public object Replace(object original, object target, object owner)
64 {
65 return original;
66 }
67
68 public Type ReturnedType
69 {
70 get { return typeof(LLUUID); }
71 }
72
73 public SqlType[] SqlTypes
74 {
75 get { return new SqlType [] { NHibernateUtil.String.SqlType }; }
76 }
77 }
78}