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