diff options
author | Mike Mazur | 2009-02-16 02:24:57 +0000 |
---|---|---|
committer | Mike Mazur | 2009-02-16 02:24:57 +0000 |
commit | 0e09b4a08beddb3b0239a3f088ab9a230b8f3979 (patch) | |
tree | 481d1cb9a60062dea6e646e0e6c5d9d87ce40b6e /OpenSim/Grid/NewAssetServer/Utils.cs | |
parent | Thank you, cmickeyb, for a patch to ass two string functions (diff) | |
download | opensim-SC_OLD-0e09b4a08beddb3b0239a3f088ab9a230b8f3979.zip opensim-SC_OLD-0e09b4a08beddb3b0239a3f088ab9a230b8f3979.tar.gz opensim-SC_OLD-0e09b4a08beddb3b0239a3f088ab9a230b8f3979.tar.bz2 opensim-SC_OLD-0e09b4a08beddb3b0239a3f088ab9a230b8f3979.tar.xz |
Adding
- NewAssetServer code
- NewAssetServer addin manifest
- example AssetServer.ini file
Diffstat (limited to 'OpenSim/Grid/NewAssetServer/Utils.cs')
-rw-r--r-- | OpenSim/Grid/NewAssetServer/Utils.cs | 1034 |
1 files changed, 1034 insertions, 0 deletions
diff --git a/OpenSim/Grid/NewAssetServer/Utils.cs b/OpenSim/Grid/NewAssetServer/Utils.cs new file mode 100644 index 0000000..5499933 --- /dev/null +++ b/OpenSim/Grid/NewAssetServer/Utils.cs | |||
@@ -0,0 +1,1034 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2008 Intel Corporation | ||
3 | * All rights reserved. | ||
4 | * Redistribution and use in source and binary forms, with or without | ||
5 | * modification, are permitted provided that the following conditions | ||
6 | * are met: | ||
7 | * | ||
8 | * -- Redistributions of source code must retain the above copyright | ||
9 | * notice, this list of conditions and the following disclaimer. | ||
10 | * -- Redistributions in binary form must reproduce the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer in the | ||
12 | * documentation and/or other materials provided with the distribution. | ||
13 | * -- Neither the name of the Intel Corporation nor the names of its | ||
14 | * contributors may be used to endorse or promote products derived from | ||
15 | * this software without specific prior written permission. | ||
16 | * | ||
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
18 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
19 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
20 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL OR ITS | ||
21 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
22 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
23 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
24 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
25 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
26 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
27 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
28 | */ | ||
29 | |||
30 | using System; | ||
31 | using System.Collections.Specialized; | ||
32 | using System.Globalization; | ||
33 | using System.Net; | ||
34 | using System.Xml; | ||
35 | using System.Xml.Serialization; | ||
36 | using OpenMetaverse; | ||
37 | using OpenMetaverse.StructuredData; | ||
38 | using HttpServer; | ||
39 | |||
40 | namespace AssetServer | ||
41 | { | ||
42 | public static class Utils | ||
43 | { | ||
44 | public static UUID GetAuthToken(IHttpRequest request) | ||
45 | { | ||
46 | UUID authToken = UUID.Zero; | ||
47 | |||
48 | string[] authHeader = request.Headers.GetValues("Authorization"); | ||
49 | if (authHeader != null && authHeader.Length == 1) | ||
50 | { | ||
51 | // Example header: | ||
52 | // Authorization: OpenGrid 65fda0b5-4446-42f5-b828-aaf644293646 | ||
53 | string[] authHeaderParts = authHeader[0].Split(' '); | ||
54 | if (authHeaderParts.Length == 2 && authHeaderParts[0] == "OpenGrid") | ||
55 | UUID.TryParse(authHeaderParts[1], out authToken); | ||
56 | } | ||
57 | |||
58 | if (authToken == UUID.Zero && request.Cookies != null) | ||
59 | { | ||
60 | // Check for an authToken cookie to make logins browser-compatible | ||
61 | RequestCookie authCookie = request.Cookies["authToken"]; | ||
62 | if (authCookie != null) | ||
63 | UUID.TryParse(authCookie.Value, out authToken); | ||
64 | } | ||
65 | |||
66 | return authToken; | ||
67 | } | ||
68 | |||
69 | public static Uri GetOpenSimUri(UUID avatarID) | ||
70 | { | ||
71 | return new Uri("http://opensim/" + avatarID.ToString()); | ||
72 | } | ||
73 | |||
74 | public static bool TryGetOpenSimUUID(Uri avatarUri, out UUID avatarID) | ||
75 | { | ||
76 | string[] parts = avatarUri.Segments; | ||
77 | return UUID.TryParse(parts[parts.Length - 1], out avatarID); | ||
78 | } | ||
79 | |||
80 | #region SL / file extension / content-type conversions | ||
81 | |||
82 | public static string SLAssetTypeToContentType(int assetType) | ||
83 | { | ||
84 | switch (assetType) | ||
85 | { | ||
86 | case 0: | ||
87 | return "image/jp2"; | ||
88 | case 1: | ||
89 | return "application/ogg"; | ||
90 | case 2: | ||
91 | return "application/x-metaverse-callingcard"; | ||
92 | case 3: | ||
93 | return "application/x-metaverse-landmark"; | ||
94 | case 5: | ||
95 | return "application/x-metaverse-clothing"; | ||
96 | case 6: | ||
97 | return "application/x-metaverse-primitive"; | ||
98 | case 7: | ||
99 | return "application/x-metaverse-notecard"; | ||
100 | case 8: | ||
101 | return "application/x-metaverse-folder"; | ||
102 | case 10: | ||
103 | return "application/x-metaverse-lsl"; | ||
104 | case 11: | ||
105 | return "application/x-metaverse-lso"; | ||
106 | case 12: | ||
107 | return "image/tga"; | ||
108 | case 13: | ||
109 | return "application/x-metaverse-bodypart"; | ||
110 | case 17: | ||
111 | return "audio/x-wav"; | ||
112 | case 19: | ||
113 | return "image/jpeg"; | ||
114 | case 20: | ||
115 | return "application/x-metaverse-animation"; | ||
116 | case 21: | ||
117 | return "application/x-metaverse-gesture"; | ||
118 | case 22: | ||
119 | return "application/x-metaverse-simstate"; | ||
120 | default: | ||
121 | return "application/octet-stream"; | ||
122 | } | ||
123 | } | ||
124 | |||
125 | public static int ContentTypeToSLAssetType(string contentType) | ||
126 | { | ||
127 | switch (contentType) | ||
128 | { | ||
129 | case "image/jp2": | ||
130 | return 0; | ||
131 | case "application/ogg": | ||
132 | return 1; | ||
133 | case "application/x-metaverse-callingcard": | ||
134 | return 2; | ||
135 | case "application/x-metaverse-landmark": | ||
136 | return 3; | ||
137 | case "application/x-metaverse-clothing": | ||
138 | return 5; | ||
139 | case "application/x-metaverse-primitive": | ||
140 | return 6; | ||
141 | case "application/x-metaverse-notecard": | ||
142 | return 7; | ||
143 | case "application/x-metaverse-lsl": | ||
144 | return 10; | ||
145 | case "application/x-metaverse-lso": | ||
146 | return 11; | ||
147 | case "image/tga": | ||
148 | return 12; | ||
149 | case "application/x-metaverse-bodypart": | ||
150 | return 13; | ||
151 | case "audio/x-wav": | ||
152 | return 17; | ||
153 | case "image/jpeg": | ||
154 | return 19; | ||
155 | case "application/x-metaverse-animation": | ||
156 | return 20; | ||
157 | case "application/x-metaverse-gesture": | ||
158 | return 21; | ||
159 | case "application/x-metaverse-simstate": | ||
160 | return 22; | ||
161 | default: | ||
162 | return -1; | ||
163 | } | ||
164 | } | ||
165 | |||
166 | public static string ContentTypeToExtension(string contentType) | ||
167 | { | ||
168 | switch (contentType) | ||
169 | { | ||
170 | case "image/jp2": | ||
171 | return "texture"; | ||
172 | case "application/ogg": | ||
173 | return "ogg"; | ||
174 | case "application/x-metaverse-callingcard": | ||
175 | return "callingcard"; | ||
176 | case "application/x-metaverse-landmark": | ||
177 | return "landmark"; | ||
178 | case "application/x-metaverse-clothing": | ||
179 | return "clothing"; | ||
180 | case "application/x-metaverse-primitive": | ||
181 | return "primitive"; | ||
182 | case "application/x-metaverse-notecard": | ||
183 | return "notecard"; | ||
184 | case "application/x-metaverse-lsl": | ||
185 | return "lsl"; | ||
186 | case "application/x-metaverse-lso": | ||
187 | return "lso"; | ||
188 | case "image/tga": | ||
189 | return "tga"; | ||
190 | case "application/x-metaverse-bodypart": | ||
191 | return "bodypart"; | ||
192 | case "audio/x-wav": | ||
193 | return "wav"; | ||
194 | case "image/jpeg": | ||
195 | return "jpg"; | ||
196 | case "application/x-metaverse-animation": | ||
197 | return "animation"; | ||
198 | case "application/x-metaverse-gesture": | ||
199 | return "gesture"; | ||
200 | case "application/x-metaverse-simstate": | ||
201 | return "simstate"; | ||
202 | default: | ||
203 | return "bin"; | ||
204 | } | ||
205 | } | ||
206 | |||
207 | public static string ExtensionToContentType(string extension) | ||
208 | { | ||
209 | switch (extension) | ||
210 | { | ||
211 | case "texture": | ||
212 | case "jp2": | ||
213 | case "j2c": | ||
214 | return "image/jp2"; | ||
215 | case "sound": | ||
216 | case "ogg": | ||
217 | return "application/ogg"; | ||
218 | case "callingcard": | ||
219 | return "application/x-metaverse-callingcard"; | ||
220 | case "landmark": | ||
221 | return "application/x-metaverse-landmark"; | ||
222 | case "clothing": | ||
223 | return "application/x-metaverse-clothing"; | ||
224 | case "primitive": | ||
225 | return "application/x-metaverse-primitive"; | ||
226 | case "notecard": | ||
227 | return "application/x-metaverse-notecard"; | ||
228 | case "lsl": | ||
229 | return "application/x-metaverse-lsl"; | ||
230 | case "lso": | ||
231 | return "application/x-metaverse-lso"; | ||
232 | case "tga": | ||
233 | return "image/tga"; | ||
234 | case "bodypart": | ||
235 | return "application/x-metaverse-bodypart"; | ||
236 | case "wav": | ||
237 | return "audio/x-wav"; | ||
238 | case "jpg": | ||
239 | case "jpeg": | ||
240 | return "image/jpeg"; | ||
241 | case "animation": | ||
242 | return "application/x-metaverse-animation"; | ||
243 | case "gesture": | ||
244 | return "application/x-metaverse-gesture"; | ||
245 | case "simstate": | ||
246 | return "application/x-metaverse-simstate"; | ||
247 | case "txt": | ||
248 | return "text/plain"; | ||
249 | case "xml": | ||
250 | return "application/xml"; | ||
251 | default: | ||
252 | return "application/octet-stream"; | ||
253 | } | ||
254 | } | ||
255 | |||
256 | #endregion SL / file extension / content-type conversions | ||
257 | |||
258 | #region XML Serialization | ||
259 | |||
260 | public class GeneratedReader : XmlSerializationReader | ||
261 | { | ||
262 | public object ReadRoot_InventoryFolderBase() | ||
263 | { | ||
264 | Reader.MoveToContent(); | ||
265 | if (Reader.LocalName != "InventoryFolderBase" || Reader.NamespaceURI != "") | ||
266 | throw CreateUnknownNodeException(); | ||
267 | return ReadObject_InventoryFolder(true, true); | ||
268 | } | ||
269 | |||
270 | public object ReadRoot_InventoryItemBase() | ||
271 | { | ||
272 | Reader.MoveToContent(); | ||
273 | if (Reader.LocalName != "InventoryItemBase" || Reader.NamespaceURI != "") | ||
274 | throw CreateUnknownNodeException(); | ||
275 | return ReadObject_InventoryItem(true, true); | ||
276 | } | ||
277 | |||
278 | public object ReadRoot_InventoryCollection() | ||
279 | { | ||
280 | Reader.MoveToContent(); | ||
281 | if (Reader.LocalName != "InventoryCollection" || Reader.NamespaceURI != "") | ||
282 | throw CreateUnknownNodeException(); | ||
283 | return ReadObject_InventoryCollection(true, true); | ||
284 | } | ||
285 | |||
286 | public InventoryFolder ReadObject_InventoryFolder(bool isNullable, bool checkType) | ||
287 | { | ||
288 | InventoryFolder ob = null; | ||
289 | if (isNullable && ReadNull()) return null; | ||
290 | |||
291 | if (checkType) | ||
292 | { | ||
293 | System.Xml.XmlQualifiedName t = GetXsiType(); | ||
294 | if (t == null) | ||
295 | { } | ||
296 | else if (t.Name != "InventoryFolderBase" || t.Namespace != "") | ||
297 | throw CreateUnknownTypeException(t); | ||
298 | } | ||
299 | |||
300 | ob = (InventoryFolder)Activator.CreateInstance(typeof(InventoryFolder), true); | ||
301 | |||
302 | Reader.MoveToElement(); | ||
303 | |||
304 | while (Reader.MoveToNextAttribute()) | ||
305 | { | ||
306 | if (IsXmlnsAttribute(Reader.Name)) | ||
307 | { | ||
308 | } | ||
309 | else | ||
310 | { | ||
311 | UnknownNode(ob); | ||
312 | } | ||
313 | } | ||
314 | |||
315 | Reader.MoveToElement(); | ||
316 | Reader.MoveToElement(); | ||
317 | if (Reader.IsEmptyElement) | ||
318 | { | ||
319 | Reader.Skip(); | ||
320 | return ob; | ||
321 | } | ||
322 | |||
323 | Reader.ReadStartElement(); | ||
324 | Reader.MoveToContent(); | ||
325 | |||
326 | bool b0 = false, b1 = false, b2 = false, b3 = false, b4 = false, b5 = false; | ||
327 | |||
328 | while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) | ||
329 | { | ||
330 | if (Reader.NodeType == System.Xml.XmlNodeType.Element) | ||
331 | { | ||
332 | if (Reader.LocalName == "Owner" && Reader.NamespaceURI == "" && !b1) | ||
333 | { | ||
334 | b1 = true; | ||
335 | ob.@Owner = ReadObject_UUID(false, true); | ||
336 | } | ||
337 | else if (Reader.LocalName == "Version" && Reader.NamespaceURI == "" && !b5) | ||
338 | { | ||
339 | b5 = true; | ||
340 | string s6 = Reader.ReadElementString(); | ||
341 | ob.@Version = UInt16.Parse(s6, CultureInfo.InvariantCulture); | ||
342 | } | ||
343 | else if (Reader.LocalName == "ID" && Reader.NamespaceURI == "" && !b3) | ||
344 | { | ||
345 | b3 = true; | ||
346 | ob.@ID = ReadObject_UUID(false, true); | ||
347 | } | ||
348 | else if (Reader.LocalName == "Type" && Reader.NamespaceURI == "" && !b4) | ||
349 | { | ||
350 | b4 = true; | ||
351 | string s7 = Reader.ReadElementString(); | ||
352 | ob.@Type = Int16.Parse(s7, CultureInfo.InvariantCulture); | ||
353 | } | ||
354 | else if (Reader.LocalName == "Name" && Reader.NamespaceURI == "" && !b0) | ||
355 | { | ||
356 | b0 = true; | ||
357 | string s8 = Reader.ReadElementString(); | ||
358 | ob.@Name = s8; | ||
359 | } | ||
360 | else if (Reader.LocalName == "ParentID" && Reader.NamespaceURI == "" && !b2) | ||
361 | { | ||
362 | b2 = true; | ||
363 | ob.@ParentID = ReadObject_UUID(false, true); | ||
364 | } | ||
365 | else | ||
366 | { | ||
367 | UnknownNode(ob); | ||
368 | } | ||
369 | } | ||
370 | else | ||
371 | UnknownNode(ob); | ||
372 | |||
373 | Reader.MoveToContent(); | ||
374 | } | ||
375 | |||
376 | ReadEndElement(); | ||
377 | |||
378 | return ob; | ||
379 | } | ||
380 | |||
381 | public InventoryItem ReadObject_InventoryItem(bool isNullable, bool checkType) | ||
382 | { | ||
383 | InventoryItem ob = null; | ||
384 | if (isNullable && ReadNull()) return null; | ||
385 | |||
386 | if (checkType) | ||
387 | { | ||
388 | System.Xml.XmlQualifiedName t = GetXsiType(); | ||
389 | if (t == null) | ||
390 | { } | ||
391 | else if (t.Name != "InventoryItemBase" || t.Namespace != "") | ||
392 | throw CreateUnknownTypeException(t); | ||
393 | } | ||
394 | |||
395 | ob = (InventoryItem)Activator.CreateInstance(typeof(InventoryItem), true); | ||
396 | |||
397 | Reader.MoveToElement(); | ||
398 | |||
399 | while (Reader.MoveToNextAttribute()) | ||
400 | { | ||
401 | if (IsXmlnsAttribute(Reader.Name)) | ||
402 | { | ||
403 | } | ||
404 | else | ||
405 | { | ||
406 | UnknownNode(ob); | ||
407 | } | ||
408 | } | ||
409 | |||
410 | Reader.MoveToElement(); | ||
411 | Reader.MoveToElement(); | ||
412 | if (Reader.IsEmptyElement) | ||
413 | { | ||
414 | Reader.Skip(); | ||
415 | return ob; | ||
416 | } | ||
417 | |||
418 | Reader.ReadStartElement(); | ||
419 | Reader.MoveToContent(); | ||
420 | |||
421 | bool b9 = false, b10 = false, b11 = false, b12 = false, b13 = false, b14 = false, b15 = false, b16 = false, b17 = false, b18 = false, b19 = false, b20 = false, b21 = false, b22 = false, b23 = false, b24 = false, b25 = false, b26 = false, b27 = false, b28 = false; | ||
422 | |||
423 | while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) | ||
424 | { | ||
425 | if (Reader.NodeType == System.Xml.XmlNodeType.Element) | ||
426 | { | ||
427 | if (Reader.LocalName == "GroupPermissions" && Reader.NamespaceURI == "" && !b20) | ||
428 | { | ||
429 | b20 = true; | ||
430 | string s29 = Reader.ReadElementString(); | ||
431 | ob.@GroupPermissions = UInt32.Parse(s29, CultureInfo.InvariantCulture); | ||
432 | } | ||
433 | else if (Reader.LocalName == "AssetType" && Reader.NamespaceURI == "" && !b21) | ||
434 | { | ||
435 | b21 = true; | ||
436 | string s30 = Reader.ReadElementString(); | ||
437 | ob.@AssetType = Int32.Parse(s30, CultureInfo.InvariantCulture); | ||
438 | } | ||
439 | else if (Reader.LocalName == "SalePrice" && Reader.NamespaceURI == "" && !b25) | ||
440 | { | ||
441 | b25 = true; | ||
442 | string s31 = Reader.ReadElementString(); | ||
443 | ob.@SalePrice = Int32.Parse(s31, CultureInfo.InvariantCulture); | ||
444 | } | ||
445 | else if (Reader.LocalName == "AssetID" && Reader.NamespaceURI == "" && !b22) | ||
446 | { | ||
447 | b22 = true; | ||
448 | ob.@AssetID = ReadObject_UUID(false, true); | ||
449 | } | ||
450 | else if (Reader.LocalName == "Folder" && Reader.NamespaceURI == "" && !b11) | ||
451 | { | ||
452 | b11 = true; | ||
453 | ob.@Folder = ReadObject_UUID(false, true); | ||
454 | } | ||
455 | else if (Reader.LocalName == "Name" && Reader.NamespaceURI == "" && !b14) | ||
456 | { | ||
457 | b14 = true; | ||
458 | string s32 = Reader.ReadElementString(); | ||
459 | ob.@Name = s32; | ||
460 | } | ||
461 | else if (Reader.LocalName == "NextPermissions" && Reader.NamespaceURI == "" && !b16) | ||
462 | { | ||
463 | b16 = true; | ||
464 | string s33 = Reader.ReadElementString(); | ||
465 | ob.@NextPermissions = UInt32.Parse(s33, CultureInfo.InvariantCulture); | ||
466 | } | ||
467 | else if (Reader.LocalName == "BasePermissions" && Reader.NamespaceURI == "" && !b18) | ||
468 | { | ||
469 | b18 = true; | ||
470 | string s34 = Reader.ReadElementString(); | ||
471 | ob.@BasePermissions = UInt32.Parse(s34, CultureInfo.InvariantCulture); | ||
472 | } | ||
473 | else if (Reader.LocalName == "ID" && Reader.NamespaceURI == "" && !b9) | ||
474 | { | ||
475 | b9 = true; | ||
476 | ob.@ID = ReadObject_UUID(false, true); | ||
477 | } | ||
478 | else if (Reader.LocalName == "Flags" && Reader.NamespaceURI == "" && !b27) | ||
479 | { | ||
480 | b27 = true; | ||
481 | string s35 = Reader.ReadElementString(); | ||
482 | ob.@Flags = UInt32.Parse(s35, CultureInfo.InvariantCulture); | ||
483 | } | ||
484 | else if (Reader.LocalName == "GroupOwned" && Reader.NamespaceURI == "" && !b24) | ||
485 | { | ||
486 | b24 = true; | ||
487 | string s36 = Reader.ReadElementString(); | ||
488 | ob.@GroupOwned = XmlConvert.ToBoolean(s36); | ||
489 | } | ||
490 | else if (Reader.LocalName == "InvType" && Reader.NamespaceURI == "" && !b10) | ||
491 | { | ||
492 | b10 = true; | ||
493 | string s37 = Reader.ReadElementString(); | ||
494 | ob.@InvType = Int32.Parse(s37, CultureInfo.InvariantCulture); | ||
495 | } | ||
496 | else if (Reader.LocalName == "GroupID" && Reader.NamespaceURI == "" && !b23) | ||
497 | { | ||
498 | b23 = true; | ||
499 | ob.@GroupID = ReadObject_UUID(false, true); | ||
500 | } | ||
501 | else if (Reader.LocalName == "Description" && Reader.NamespaceURI == "" && !b15) | ||
502 | { | ||
503 | b15 = true; | ||
504 | string s38 = Reader.ReadElementString(); | ||
505 | ob.@Description = s38; | ||
506 | } | ||
507 | else if (Reader.LocalName == "CreationDate" && Reader.NamespaceURI == "" && !b28) | ||
508 | { | ||
509 | b28 = true; | ||
510 | string s39 = Reader.ReadElementString(); | ||
511 | ob.@CreationDate = Int32.Parse(s39, CultureInfo.InvariantCulture); | ||
512 | } | ||
513 | else if (Reader.LocalName == "EveryOnePermissions" && Reader.NamespaceURI == "" && !b19) | ||
514 | { | ||
515 | b19 = true; | ||
516 | string s40 = Reader.ReadElementString(); | ||
517 | ob.@EveryOnePermissions = UInt32.Parse(s40, CultureInfo.InvariantCulture); | ||
518 | } | ||
519 | else if (Reader.LocalName == "Creator" && Reader.NamespaceURI == "" && !b13) | ||
520 | { | ||
521 | b13 = true; | ||
522 | ob.@Creator = ReadObject_UUID(false, true); | ||
523 | } | ||
524 | else if (Reader.LocalName == "Owner" && Reader.NamespaceURI == "" && !b12) | ||
525 | { | ||
526 | b12 = true; | ||
527 | ob.@Owner = ReadObject_UUID(false, true); | ||
528 | } | ||
529 | else if (Reader.LocalName == "SaleType" && Reader.NamespaceURI == "" && !b26) | ||
530 | { | ||
531 | b26 = true; | ||
532 | string s41 = Reader.ReadElementString(); | ||
533 | ob.@SaleType = byte.Parse(s41, CultureInfo.InvariantCulture); | ||
534 | } | ||
535 | else if (Reader.LocalName == "CurrentPermissions" && Reader.NamespaceURI == "" && !b17) | ||
536 | { | ||
537 | b17 = true; | ||
538 | string s42 = Reader.ReadElementString(); | ||
539 | ob.@CurrentPermissions = UInt32.Parse(s42, CultureInfo.InvariantCulture); | ||
540 | } | ||
541 | else | ||
542 | { | ||
543 | UnknownNode(ob); | ||
544 | } | ||
545 | } | ||
546 | else | ||
547 | UnknownNode(ob); | ||
548 | |||
549 | Reader.MoveToContent(); | ||
550 | } | ||
551 | |||
552 | ReadEndElement(); | ||
553 | |||
554 | return ob; | ||
555 | } | ||
556 | |||
557 | public InventoryCollection ReadObject_InventoryCollection(bool isNullable, bool checkType) | ||
558 | { | ||
559 | InventoryCollection ob = null; | ||
560 | if (isNullable && ReadNull()) return null; | ||
561 | |||
562 | if (checkType) | ||
563 | { | ||
564 | System.Xml.XmlQualifiedName t = GetXsiType(); | ||
565 | if (t == null) | ||
566 | { } | ||
567 | else if (t.Name != "InventoryCollection" || t.Namespace != "") | ||
568 | throw CreateUnknownTypeException(t); | ||
569 | } | ||
570 | |||
571 | ob = (InventoryCollection)Activator.CreateInstance(typeof(InventoryCollection), true); | ||
572 | |||
573 | Reader.MoveToElement(); | ||
574 | |||
575 | while (Reader.MoveToNextAttribute()) | ||
576 | { | ||
577 | if (IsXmlnsAttribute(Reader.Name)) | ||
578 | { | ||
579 | } | ||
580 | else | ||
581 | { | ||
582 | UnknownNode(ob); | ||
583 | } | ||
584 | } | ||
585 | |||
586 | Reader.MoveToElement(); | ||
587 | Reader.MoveToElement(); | ||
588 | if (Reader.IsEmptyElement) | ||
589 | { | ||
590 | Reader.Skip(); | ||
591 | if (ob.@Folders == null) | ||
592 | { | ||
593 | ob.@Folders = new System.Collections.Generic.Dictionary<UUID, InventoryFolder>(); | ||
594 | } | ||
595 | if (ob.@Items == null) | ||
596 | { | ||
597 | ob.@Items = new System.Collections.Generic.Dictionary<UUID, InventoryItem>(); | ||
598 | } | ||
599 | return ob; | ||
600 | } | ||
601 | |||
602 | Reader.ReadStartElement(); | ||
603 | Reader.MoveToContent(); | ||
604 | |||
605 | bool b43 = false, b44 = false, b45 = false; | ||
606 | |||
607 | while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) | ||
608 | { | ||
609 | if (Reader.NodeType == System.Xml.XmlNodeType.Element) | ||
610 | { | ||
611 | if (Reader.LocalName == "UserID" && Reader.NamespaceURI == "" && !b45) | ||
612 | { | ||
613 | b45 = true; | ||
614 | ob.@UserID = ReadObject_UUID(false, true); | ||
615 | } | ||
616 | else if (Reader.LocalName == "Items" && Reader.NamespaceURI == "" && !b44) | ||
617 | { | ||
618 | System.Collections.Generic.Dictionary<UUID, InventoryItem> o46 = ob.@Items; | ||
619 | if (((object)o46) == null) | ||
620 | { | ||
621 | o46 = new System.Collections.Generic.Dictionary<UUID, InventoryItem>(); | ||
622 | ob.@Items = o46; | ||
623 | } | ||
624 | if (Reader.IsEmptyElement) | ||
625 | { | ||
626 | Reader.Skip(); | ||
627 | } | ||
628 | else | ||
629 | { | ||
630 | int n47 = 0; | ||
631 | Reader.ReadStartElement(); | ||
632 | Reader.MoveToContent(); | ||
633 | |||
634 | while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) | ||
635 | { | ||
636 | if (Reader.NodeType == System.Xml.XmlNodeType.Element) | ||
637 | { | ||
638 | if (Reader.LocalName == "InventoryItemBase" && Reader.NamespaceURI == "") | ||
639 | { | ||
640 | if (((object)o46) == null) | ||
641 | throw CreateReadOnlyCollectionException("System.Collections.Generic.List<InventoryItemBase>"); | ||
642 | InventoryItem item = ReadObject_InventoryItem(true, true); | ||
643 | o46.Add(item.ID, item); | ||
644 | n47++; | ||
645 | } | ||
646 | else UnknownNode(null); | ||
647 | } | ||
648 | else UnknownNode(null); | ||
649 | |||
650 | Reader.MoveToContent(); | ||
651 | } | ||
652 | ReadEndElement(); | ||
653 | } | ||
654 | b44 = true; | ||
655 | } | ||
656 | else if (Reader.LocalName == "Folders" && Reader.NamespaceURI == "" && !b43) | ||
657 | { | ||
658 | System.Collections.Generic.Dictionary<UUID, InventoryFolder> o48 = ob.@Folders; | ||
659 | if (((object)o48) == null) | ||
660 | { | ||
661 | o48 = new System.Collections.Generic.Dictionary<UUID, InventoryFolder>(); | ||
662 | ob.@Folders = o48; | ||
663 | } | ||
664 | if (Reader.IsEmptyElement) | ||
665 | { | ||
666 | Reader.Skip(); | ||
667 | } | ||
668 | else | ||
669 | { | ||
670 | int n49 = 0; | ||
671 | Reader.ReadStartElement(); | ||
672 | Reader.MoveToContent(); | ||
673 | |||
674 | while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) | ||
675 | { | ||
676 | if (Reader.NodeType == System.Xml.XmlNodeType.Element) | ||
677 | { | ||
678 | if (Reader.LocalName == "InventoryFolderBase" && Reader.NamespaceURI == "") | ||
679 | { | ||
680 | if (((object)o48) == null) | ||
681 | throw CreateReadOnlyCollectionException("System.Collections.Generic.List<InventoryFolderBase>"); | ||
682 | InventoryFolder folder = ReadObject_InventoryFolder(true, true); | ||
683 | o48.Add(folder.ID, folder); | ||
684 | n49++; | ||
685 | } | ||
686 | else UnknownNode(null); | ||
687 | } | ||
688 | else UnknownNode(null); | ||
689 | |||
690 | Reader.MoveToContent(); | ||
691 | } | ||
692 | ReadEndElement(); | ||
693 | } | ||
694 | b43 = true; | ||
695 | } | ||
696 | else | ||
697 | { | ||
698 | UnknownNode(ob); | ||
699 | } | ||
700 | } | ||
701 | else | ||
702 | UnknownNode(ob); | ||
703 | |||
704 | Reader.MoveToContent(); | ||
705 | } | ||
706 | if (ob.@Folders == null) | ||
707 | { | ||
708 | ob.@Folders = new System.Collections.Generic.Dictionary<UUID, InventoryFolder>(); | ||
709 | } | ||
710 | if (ob.@Items == null) | ||
711 | { | ||
712 | ob.@Items = new System.Collections.Generic.Dictionary<UUID, InventoryItem>(); | ||
713 | } | ||
714 | |||
715 | ReadEndElement(); | ||
716 | |||
717 | return ob; | ||
718 | } | ||
719 | |||
720 | public OpenMetaverse.UUID ReadObject_UUID(bool isNullable, bool checkType) | ||
721 | { | ||
722 | OpenMetaverse.UUID ob = (OpenMetaverse.UUID)Activator.CreateInstance(typeof(OpenMetaverse.UUID), true); | ||
723 | System.Xml.XmlQualifiedName t = GetXsiType(); | ||
724 | if (t == null) | ||
725 | { } | ||
726 | else if (t.Name != "UUID" || t.Namespace != "") | ||
727 | throw CreateUnknownTypeException(t); | ||
728 | |||
729 | Reader.MoveToElement(); | ||
730 | |||
731 | while (Reader.MoveToNextAttribute()) | ||
732 | { | ||
733 | if (IsXmlnsAttribute(Reader.Name)) | ||
734 | { | ||
735 | } | ||
736 | else | ||
737 | { | ||
738 | UnknownNode(ob); | ||
739 | } | ||
740 | } | ||
741 | |||
742 | Reader.MoveToElement(); | ||
743 | Reader.MoveToElement(); | ||
744 | if (Reader.IsEmptyElement) | ||
745 | { | ||
746 | Reader.Skip(); | ||
747 | return ob; | ||
748 | } | ||
749 | |||
750 | Reader.ReadStartElement(); | ||
751 | Reader.MoveToContent(); | ||
752 | |||
753 | bool b52 = false; | ||
754 | |||
755 | while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) | ||
756 | { | ||
757 | if (Reader.NodeType == System.Xml.XmlNodeType.Element) | ||
758 | { | ||
759 | if (Reader.LocalName == "Guid" && Reader.NamespaceURI == "" && !b52) | ||
760 | { | ||
761 | b52 = true; | ||
762 | string s53 = Reader.ReadElementString(); | ||
763 | ob.@Guid = XmlConvert.ToGuid(s53); | ||
764 | } | ||
765 | else | ||
766 | { | ||
767 | UnknownNode(ob); | ||
768 | } | ||
769 | } | ||
770 | else | ||
771 | UnknownNode(ob); | ||
772 | |||
773 | Reader.MoveToContent(); | ||
774 | } | ||
775 | |||
776 | ReadEndElement(); | ||
777 | |||
778 | return ob; | ||
779 | } | ||
780 | |||
781 | protected override void InitCallbacks() | ||
782 | { | ||
783 | } | ||
784 | |||
785 | protected override void InitIDs() | ||
786 | { | ||
787 | } | ||
788 | } | ||
789 | |||
790 | public class GeneratedWriter : XmlSerializationWriter | ||
791 | { | ||
792 | const string xmlNamespace = "http://www.w3.org/2000/xmlns/"; | ||
793 | static readonly System.Reflection.MethodInfo toBinHexStringMethod = typeof(XmlConvert).GetMethod("ToBinHexString", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic, null, new Type[] { typeof(byte[]) }, null); | ||
794 | static string ToBinHexString(byte[] input) | ||
795 | { | ||
796 | return input == null ? null : (string)toBinHexStringMethod.Invoke(null, new object[] { input }); | ||
797 | } | ||
798 | public void WriteRoot_InventoryFolder(object o) | ||
799 | { | ||
800 | WriteStartDocument(); | ||
801 | InventoryFolder ob = (InventoryFolder)o; | ||
802 | TopLevelElement(); | ||
803 | WriteObject_InventoryFolder(ob, "InventoryFolderBase", "", true, false, true); | ||
804 | } | ||
805 | |||
806 | public void WriteRoot_InventoryItem(object o) | ||
807 | { | ||
808 | WriteStartDocument(); | ||
809 | InventoryItem ob = (InventoryItem)o; | ||
810 | TopLevelElement(); | ||
811 | WriteObject_InventoryItem(ob, "InventoryItemBase", "", true, false, true); | ||
812 | } | ||
813 | |||
814 | public void WriteRoot_InventoryCollection(object o) | ||
815 | { | ||
816 | WriteStartDocument(); | ||
817 | InventoryCollection ob = (InventoryCollection)o; | ||
818 | TopLevelElement(); | ||
819 | WriteObject_InventoryCollection(ob, "InventoryCollection", "", true, false, true); | ||
820 | } | ||
821 | |||
822 | void WriteObject_InventoryFolder(InventoryFolder ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem) | ||
823 | { | ||
824 | if (((object)ob) == null) | ||
825 | { | ||
826 | if (isNullable) | ||
827 | WriteNullTagLiteral(element, namesp); | ||
828 | return; | ||
829 | } | ||
830 | |||
831 | System.Type type = ob.GetType(); | ||
832 | if (type == typeof(InventoryFolder)) | ||
833 | { } | ||
834 | else | ||
835 | { | ||
836 | throw CreateUnknownTypeException(ob); | ||
837 | } | ||
838 | |||
839 | if (writeWrappingElem) | ||
840 | { | ||
841 | WriteStartElement(element, namesp, ob); | ||
842 | } | ||
843 | |||
844 | if (needType) WriteXsiType("InventoryFolderBase", ""); | ||
845 | |||
846 | WriteElementString("Name", "", ob.@Name); | ||
847 | WriteObject_UUID(ob.@Owner, "Owner", "", false, false, true); | ||
848 | WriteObject_UUID(ob.@ParentID, "ParentID", "", false, false, true); | ||
849 | WriteObject_UUID(ob.@ID, "ID", "", false, false, true); | ||
850 | WriteElementString("Type", "", ob.@Type.ToString(CultureInfo.InvariantCulture)); | ||
851 | WriteElementString("Version", "", ob.@Version.ToString(CultureInfo.InvariantCulture)); | ||
852 | if (writeWrappingElem) WriteEndElement(ob); | ||
853 | } | ||
854 | |||
855 | void WriteObject_InventoryItem(InventoryItem ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem) | ||
856 | { | ||
857 | if (((object)ob) == null) | ||
858 | { | ||
859 | if (isNullable) | ||
860 | WriteNullTagLiteral(element, namesp); | ||
861 | return; | ||
862 | } | ||
863 | |||
864 | System.Type type = ob.GetType(); | ||
865 | if (type == typeof(InventoryItem)) | ||
866 | { } | ||
867 | else | ||
868 | { | ||
869 | throw CreateUnknownTypeException(ob); | ||
870 | } | ||
871 | |||
872 | if (writeWrappingElem) | ||
873 | { | ||
874 | WriteStartElement(element, namesp, ob); | ||
875 | } | ||
876 | |||
877 | if (needType) WriteXsiType("InventoryItemBase", ""); | ||
878 | |||
879 | WriteObject_UUID(ob.@ID, "ID", "", false, false, true); | ||
880 | WriteElementString("InvType", "", ob.@InvType.ToString(CultureInfo.InvariantCulture)); | ||
881 | WriteObject_UUID(ob.@Folder, "Folder", "", false, false, true); | ||
882 | WriteObject_UUID(ob.@Owner, "Owner", "", false, false, true); | ||
883 | WriteObject_UUID(ob.@Creator, "Creator", "", false, false, true); | ||
884 | WriteElementString("Name", "", ob.@Name); | ||
885 | WriteElementString("Description", "", ob.@Description); | ||
886 | WriteElementString("NextPermissions", "", ob.@NextPermissions.ToString(CultureInfo.InvariantCulture)); | ||
887 | WriteElementString("CurrentPermissions", "", ob.@CurrentPermissions.ToString(CultureInfo.InvariantCulture)); | ||
888 | WriteElementString("BasePermissions", "", ob.@BasePermissions.ToString(CultureInfo.InvariantCulture)); | ||
889 | WriteElementString("EveryOnePermissions", "", ob.@EveryOnePermissions.ToString(CultureInfo.InvariantCulture)); | ||
890 | WriteElementString("GroupPermissions", "", ob.@GroupPermissions.ToString(CultureInfo.InvariantCulture)); | ||
891 | WriteElementString("AssetType", "", ob.@AssetType.ToString(CultureInfo.InvariantCulture)); | ||
892 | WriteObject_UUID(ob.@AssetID, "AssetID", "", false, false, true); | ||
893 | WriteObject_UUID(ob.@GroupID, "GroupID", "", false, false, true); | ||
894 | WriteElementString("GroupOwned", "", (ob.@GroupOwned ? "true" : "false")); | ||
895 | WriteElementString("SalePrice", "", ob.@SalePrice.ToString(CultureInfo.InvariantCulture)); | ||
896 | WriteElementString("SaleType", "", ob.@SaleType.ToString(CultureInfo.InvariantCulture)); | ||
897 | WriteElementString("Flags", "", ob.@Flags.ToString(CultureInfo.InvariantCulture)); | ||
898 | WriteElementString("CreationDate", "", ob.@CreationDate.ToString(CultureInfo.InvariantCulture)); | ||
899 | if (writeWrappingElem) WriteEndElement(ob); | ||
900 | } | ||
901 | |||
902 | void WriteObject_InventoryCollection(InventoryCollection ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem) | ||
903 | { | ||
904 | if (((object)ob) == null) | ||
905 | { | ||
906 | if (isNullable) | ||
907 | WriteNullTagLiteral(element, namesp); | ||
908 | return; | ||
909 | } | ||
910 | |||
911 | System.Type type = ob.GetType(); | ||
912 | if (type == typeof(InventoryCollection)) | ||
913 | { } | ||
914 | else | ||
915 | { | ||
916 | throw CreateUnknownTypeException(ob); | ||
917 | } | ||
918 | |||
919 | if (writeWrappingElem) | ||
920 | { | ||
921 | WriteStartElement(element, namesp, ob); | ||
922 | } | ||
923 | |||
924 | if (needType) WriteXsiType("InventoryCollection", ""); | ||
925 | |||
926 | if (ob.@Folders != null) | ||
927 | { | ||
928 | WriteStartElement("Folders", "", ob.@Folders); | ||
929 | foreach (InventoryFolder folder in ob.Folders.Values) | ||
930 | { | ||
931 | WriteObject_InventoryFolder(folder, "InventoryFolderBase", "", true, false, true); | ||
932 | } | ||
933 | WriteEndElement(ob.@Folders); | ||
934 | } | ||
935 | if (ob.@Items != null) | ||
936 | { | ||
937 | WriteStartElement("Items", "", ob.@Items); | ||
938 | foreach (InventoryItem item in ob.Items.Values) | ||
939 | { | ||
940 | WriteObject_InventoryItem(item, "InventoryItemBase", "", true, false, true); | ||
941 | } | ||
942 | WriteEndElement(ob.@Items); | ||
943 | } | ||
944 | WriteObject_UUID(ob.@UserID, "UserID", "", false, false, true); | ||
945 | if (writeWrappingElem) WriteEndElement(ob); | ||
946 | } | ||
947 | |||
948 | void WriteObject_UUID(OpenMetaverse.UUID ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem) | ||
949 | { | ||
950 | System.Type type = ob.GetType(); | ||
951 | if (type == typeof(OpenMetaverse.UUID)) | ||
952 | { } | ||
953 | else | ||
954 | { | ||
955 | throw CreateUnknownTypeException(ob); | ||
956 | } | ||
957 | |||
958 | if (writeWrappingElem) | ||
959 | { | ||
960 | WriteStartElement(element, namesp, ob); | ||
961 | } | ||
962 | |||
963 | if (needType) WriteXsiType("UUID", ""); | ||
964 | |||
965 | WriteElementString("Guid", "", XmlConvert.ToString(ob.@Guid)); | ||
966 | if (writeWrappingElem) WriteEndElement(ob); | ||
967 | } | ||
968 | |||
969 | protected override void InitCallbacks() | ||
970 | { | ||
971 | } | ||
972 | |||
973 | } | ||
974 | |||
975 | public class BaseXmlSerializer : System.Xml.Serialization.XmlSerializer | ||
976 | { | ||
977 | protected override System.Xml.Serialization.XmlSerializationReader CreateReader() | ||
978 | { | ||
979 | return new GeneratedReader(); | ||
980 | } | ||
981 | |||
982 | protected override System.Xml.Serialization.XmlSerializationWriter CreateWriter() | ||
983 | { | ||
984 | return new GeneratedWriter(); | ||
985 | } | ||
986 | |||
987 | public override bool CanDeserialize(System.Xml.XmlReader xmlReader) | ||
988 | { | ||
989 | return true; | ||
990 | } | ||
991 | } | ||
992 | |||
993 | public sealed class InventoryFolderSerializer : BaseXmlSerializer | ||
994 | { | ||
995 | protected override void Serialize(object obj, System.Xml.Serialization.XmlSerializationWriter writer) | ||
996 | { | ||
997 | ((GeneratedWriter)writer).WriteRoot_InventoryFolder(obj); | ||
998 | } | ||
999 | |||
1000 | protected override object Deserialize(System.Xml.Serialization.XmlSerializationReader reader) | ||
1001 | { | ||
1002 | return ((GeneratedReader)reader).ReadRoot_InventoryFolderBase(); | ||
1003 | } | ||
1004 | } | ||
1005 | |||
1006 | public sealed class InventoryItemSerializer : BaseXmlSerializer | ||
1007 | { | ||
1008 | protected override void Serialize(object obj, System.Xml.Serialization.XmlSerializationWriter writer) | ||
1009 | { | ||
1010 | ((GeneratedWriter)writer).WriteRoot_InventoryItem(obj); | ||
1011 | } | ||
1012 | |||
1013 | protected override object Deserialize(System.Xml.Serialization.XmlSerializationReader reader) | ||
1014 | { | ||
1015 | return ((GeneratedReader)reader).ReadRoot_InventoryItemBase(); | ||
1016 | } | ||
1017 | } | ||
1018 | |||
1019 | public sealed class InventoryCollectionSerializer : BaseXmlSerializer | ||
1020 | { | ||
1021 | protected override void Serialize(object obj, System.Xml.Serialization.XmlSerializationWriter writer) | ||
1022 | { | ||
1023 | ((GeneratedWriter)writer).WriteRoot_InventoryCollection(obj); | ||
1024 | } | ||
1025 | |||
1026 | protected override object Deserialize(System.Xml.Serialization.XmlSerializationReader reader) | ||
1027 | { | ||
1028 | return ((GeneratedReader)reader).ReadRoot_InventoryCollection(); | ||
1029 | } | ||
1030 | } | ||
1031 | |||
1032 | #endregion XML Serialization | ||
1033 | } | ||
1034 | } | ||