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