aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/DBGuids.cs
diff options
context:
space:
mode:
authorMelanie2010-05-21 03:51:58 +0100
committerMelanie2010-05-21 03:51:58 +0100
commita92780fe5f31a38b2f00459ef00ca28127a60dcf (patch)
treef89850a27564abd01f1b3aaf72aa24001e165a26 /OpenSim/Data/DBGuids.cs
parentRefactor scene presence list for lockless iteration. Lock contention will now... (diff)
parentCleaned up MySql migrations a bit more, got rid of all old-form migration fil... (diff)
downloadopensim-SC-a92780fe5f31a38b2f00459ef00ca28127a60dcf.zip
opensim-SC-a92780fe5f31a38b2f00459ef00ca28127a60dcf.tar.gz
opensim-SC-a92780fe5f31a38b2f00459ef00ca28127a60dcf.tar.bz2
opensim-SC-a92780fe5f31a38b2f00459ef00ca28127a60dcf.tar.xz
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/DBGuids.cs44
1 files changed, 44 insertions, 0 deletions
diff --git a/OpenSim/Data/DBGuids.cs b/OpenSim/Data/DBGuids.cs
new file mode 100644
index 0000000..fb6832b
--- /dev/null
+++ b/OpenSim/Data/DBGuids.cs
@@ -0,0 +1,44 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenMetaverse;
5
6namespace OpenSim.Data
7{
8
9 public static class DBGuid
10 {
11 /// <summary>This function converts a value returned from the database in one of the
12 /// supported formats into a UUID. This function is not actually DBMS-specific right
13 /// now
14 ///
15 /// </summary>
16 /// <param name="id"></param>
17 /// <returns></returns>
18 public static UUID FromDB(object id)
19 {
20 if( (id == null) || (id == DBNull.Value))
21 return UUID.Zero;
22
23 if (id.GetType() == typeof(Guid))
24 return new UUID((Guid)id);
25
26 if (id.GetType() == typeof(byte[]))
27 {
28 if (((byte[])id).Length == 0)
29 return UUID.Zero;
30 else if (((byte[])id).Length == 16)
31 return new UUID((byte[])id, 0);
32 }
33 else if (id.GetType() == typeof(string))
34 {
35 if (((string)id).Length == 0)
36 return UUID.Zero;
37 else if (((string)id).Length == 36)
38 return new UUID((string)id);
39 }
40
41 throw new Exception("Failed to convert db value to UUID: " + id.ToString());
42 }
43 }
44}