aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/OSUUID.cs
diff options
context:
space:
mode:
authorSean Dague2008-04-09 14:38:23 +0000
committerSean Dague2008-04-09 14:38:23 +0000
commitf8cb4f993d1e35cb3cbd67adb571e91a0a033a1c (patch)
tree8f2db03dc5d770c7958999a87db224295928d050 /OpenSim/Framework/OSUUID.cs
parentchecking in a chunk of work because I think I'm tackling (diff)
downloadopensim-SC-f8cb4f993d1e35cb3cbd67adb571e91a0a033a1c.zip
opensim-SC-f8cb4f993d1e35cb3cbd67adb571e91a0a033a1c.tar.gz
opensim-SC-f8cb4f993d1e35cb3cbd67adb571e91a0a033a1c.tar.bz2
opensim-SC-f8cb4f993d1e35cb3cbd67adb571e91a0a033a1c.tar.xz
check in an OSUUID wrapper as potential replacement
for LLUUID in most of our code. Like LLUUID, this is basically just a box type on the .NET Guid.
Diffstat (limited to 'OpenSim/Framework/OSUUID.cs')
-rw-r--r--OpenSim/Framework/OSUUID.cs85
1 files changed, 85 insertions, 0 deletions
diff --git a/OpenSim/Framework/OSUUID.cs b/OpenSim/Framework/OSUUID.cs
new file mode 100644
index 0000000..8a45290
--- /dev/null
+++ b/OpenSim/Framework/OSUUID.cs
@@ -0,0 +1,85 @@
1// OSUUID.cs created with MonoDevelop
2// User: sdague at 10:17 AMĀ 4/9/2008
3//
4// To change standard headers go to Edit->Preferences->Coding->Standard Headers
5//
6
7using System;
8using libsecondlife;
9
10namespace OpenSim.Framework
11{
12 [Serializable]
13 public struct OSUUID: IComparable
14 {
15 public Guid UUID;
16
17 /* Constructors */
18 public OSUUID(string s)
19 {
20 if (s == null)
21 UUID = new Guid();
22 else
23 UUID = new Guid(s);
24 }
25
26 public OSUUID(Guid g)
27 {
28 UUID = g;
29 }
30
31 public OSUUID(LLUUID l)
32 {
33 UUID = l.UUID;
34 }
35
36 public OSUUID(ulong u)
37 {
38 UUID = new Guid(0, 0, 0, BitConverter.GetBytes(u));
39 }
40
41 // out conversion
42 public string ToString()
43 {
44 return UUID.ToString();
45 }
46
47 public LLUUID ToLLUUID()
48 {
49 return new LLUUID(UUID);
50 }
51
52 // for comparison bits
53 public override int GetHashCode()
54 {
55 return UUID.GetHashCode();
56 }
57
58 public override bool Equals(object o)
59 {
60 if (!(o is LLUUID)) return false;
61
62 OSUUID uuid = (OSUUID)o;
63 return UUID == uuid.UUID;
64 }
65
66 public int CompareTo(object obj)
67 {
68 if (obj is OSUUID)
69 {
70 OSUUID ID = (OSUUID)obj;
71 return this.UUID.CompareTo(ID.UUID);
72 }
73
74 throw new ArgumentException("object is not a OSUUID");
75 }
76
77 // Static methods
78 public static OSUUID Random()
79 {
80 return new OSUUID(Guid.NewGuid());
81 }
82
83 public static readonly OSUUID Zero = new OSUUID();
84 }
85}