diff options
Diffstat (limited to 'OpenSim/Grid/AssetInventoryServer/Metadata.cs')
-rw-r--r-- | OpenSim/Grid/AssetInventoryServer/Metadata.cs | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/OpenSim/Grid/AssetInventoryServer/Metadata.cs b/OpenSim/Grid/AssetInventoryServer/Metadata.cs deleted file mode 100644 index ebd379d..0000000 --- a/OpenSim/Grid/AssetInventoryServer/Metadata.cs +++ /dev/null | |||
@@ -1,84 +0,0 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using OpenMetaverse; | ||
4 | using OpenMetaverse.StructuredData; | ||
5 | |||
6 | namespace OpenSim.Grid.AssetInventoryServer | ||
7 | { | ||
8 | public class Metadata | ||
9 | { | ||
10 | public UUID ID; | ||
11 | public string Name; | ||
12 | public string Description; | ||
13 | public DateTime CreationDate; | ||
14 | public string ContentType; | ||
15 | public byte[] SHA1; | ||
16 | public bool Temporary; | ||
17 | public Dictionary<string, Uri> Methods = new Dictionary<string, Uri>(); | ||
18 | public OSDMap ExtraData; | ||
19 | |||
20 | public OSDMap SerializeToOSD() | ||
21 | { | ||
22 | OSDMap osdata = new OSDMap(); | ||
23 | |||
24 | if (ID != UUID.Zero) osdata["id"] = OSD.FromUUID(ID); | ||
25 | osdata["name"] = OSD.FromString(Name); | ||
26 | osdata["description"] = OSD.FromString(Description); | ||
27 | osdata["creation_date"] = OSD.FromDate(CreationDate); | ||
28 | osdata["type"] = OSD.FromString(ContentType); | ||
29 | osdata["sha1"] = OSD.FromBinary(SHA1); | ||
30 | osdata["temporary"] = OSD.FromBoolean(Temporary); | ||
31 | |||
32 | OSDMap methods = new OSDMap(Methods.Count); | ||
33 | foreach (KeyValuePair<string, Uri> kvp in Methods) | ||
34 | methods.Add(kvp.Key, OSD.FromUri(kvp.Value)); | ||
35 | osdata["methods"] = methods; | ||
36 | |||
37 | if (ExtraData != null) osdata["extra_data"] = ExtraData; | ||
38 | |||
39 | return osdata; | ||
40 | } | ||
41 | |||
42 | public byte[] SerializeToBytes() | ||
43 | { | ||
44 | LitJson.JsonData jsonData = OSDParser.SerializeJson(SerializeToOSD()); | ||
45 | return System.Text.Encoding.UTF8.GetBytes(jsonData.ToJson()); | ||
46 | } | ||
47 | |||
48 | public void Deserialize(byte[] data) | ||
49 | { | ||
50 | OSD osdata = OSDParser.DeserializeJson(System.Text.Encoding.UTF8.GetString(data)); | ||
51 | Deserialize(osdata); | ||
52 | } | ||
53 | |||
54 | public void Deserialize(string data) | ||
55 | { | ||
56 | OSD osdata = OSDParser.DeserializeJson(data); | ||
57 | Deserialize(osdata); | ||
58 | } | ||
59 | |||
60 | public void Deserialize(OSD osdata) | ||
61 | { | ||
62 | if (osdata.Type == OSDType.Map) | ||
63 | { | ||
64 | OSDMap map = (OSDMap)osdata; | ||
65 | ID = map["id"].AsUUID(); | ||
66 | Name = map["name"].AsString(); | ||
67 | Description = map["description"].AsString(); | ||
68 | CreationDate = map["creation_date"].AsDate(); | ||
69 | ContentType = map["type"].AsString(); | ||
70 | SHA1 = map["sha1"].AsBinary(); | ||
71 | Temporary = map["temporary"].AsBoolean(); | ||
72 | |||
73 | OSDMap methods = map["methods"] as OSDMap; | ||
74 | if (methods != null) | ||
75 | { | ||
76 | foreach (KeyValuePair<string, OSD> kvp in methods) | ||
77 | Methods.Add(kvp.Key, kvp.Value.AsUri()); | ||
78 | } | ||
79 | |||
80 | ExtraData = map["extra_data"] as OSDMap; | ||
81 | } | ||
82 | } | ||
83 | } | ||
84 | } | ||