From f8cb4f993d1e35cb3cbd67adb571e91a0a033a1c Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Wed, 9 Apr 2008 14:38:23 +0000 Subject: 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. --- OpenSim/Framework/OSUUID.cs | 85 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 OpenSim/Framework/OSUUID.cs (limited to 'OpenSim') 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 @@ +// OSUUID.cs created with MonoDevelop +// User: sdague at 10:17 AMĀ 4/9/2008 +// +// To change standard headers go to Edit->Preferences->Coding->Standard Headers +// + +using System; +using libsecondlife; + +namespace OpenSim.Framework +{ + [Serializable] + public struct OSUUID: IComparable + { + public Guid UUID; + + /* Constructors */ + public OSUUID(string s) + { + if (s == null) + UUID = new Guid(); + else + UUID = new Guid(s); + } + + public OSUUID(Guid g) + { + UUID = g; + } + + public OSUUID(LLUUID l) + { + UUID = l.UUID; + } + + public OSUUID(ulong u) + { + UUID = new Guid(0, 0, 0, BitConverter.GetBytes(u)); + } + + // out conversion + public string ToString() + { + return UUID.ToString(); + } + + public LLUUID ToLLUUID() + { + return new LLUUID(UUID); + } + + // for comparison bits + public override int GetHashCode() + { + return UUID.GetHashCode(); + } + + public override bool Equals(object o) + { + if (!(o is LLUUID)) return false; + + OSUUID uuid = (OSUUID)o; + return UUID == uuid.UUID; + } + + public int CompareTo(object obj) + { + if (obj is OSUUID) + { + OSUUID ID = (OSUUID)obj; + return this.UUID.CompareTo(ID.UUID); + } + + throw new ArgumentException("object is not a OSUUID"); + } + + // Static methods + public static OSUUID Random() + { + return new OSUUID(Guid.NewGuid()); + } + + public static readonly OSUUID Zero = new OSUUID(); + } +} -- cgit v1.1