diff options
author | Diva Canto | 2010-11-27 11:40:54 -0800 |
---|---|---|
committer | Diva Canto | 2010-11-27 11:40:54 -0800 |
commit | ca8d0157333823b549c7ae36b40ea3c05045fc25 (patch) | |
tree | 267f4219ef8447178e494c7637cf7a1d89367460 /OpenSim/Framework/Util.cs | |
parent | Creator information preserved upon HG transfers. (diff) | |
download | opensim-SC-ca8d0157333823b549c7ae36b40ea3c05045fc25.zip opensim-SC-ca8d0157333823b549c7ae36b40ea3c05045fc25.tar.gz opensim-SC-ca8d0157333823b549c7ae36b40ea3c05045fc25.tar.bz2 opensim-SC-ca8d0157333823b549c7ae36b40ea3c05045fc25.tar.xz |
Changed the parser for InventoryItem deserialization. Moved some utility functions around.
Diffstat (limited to 'OpenSim/Framework/Util.cs')
-rw-r--r-- | OpenSim/Framework/Util.cs | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index e8f8e01..101ece4 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -1558,5 +1558,66 @@ namespace OpenSim.Framework | |||
1558 | return string.Empty; | 1558 | return string.Empty; |
1559 | } | 1559 | } |
1560 | 1560 | ||
1561 | public static UUID ReadUUID(XmlTextReader reader, string name) | ||
1562 | { | ||
1563 | UUID id; | ||
1564 | string idStr; | ||
1565 | |||
1566 | reader.ReadStartElement(name); | ||
1567 | |||
1568 | if (reader.Name == "Guid") | ||
1569 | idStr = reader.ReadElementString("Guid"); | ||
1570 | else if (reader.Name == "UUID") | ||
1571 | idStr = reader.ReadElementString("UUID"); | ||
1572 | else // no leading tag | ||
1573 | idStr = reader.ReadContentAsString(); | ||
1574 | UUID.TryParse(idStr, out id); | ||
1575 | reader.ReadEndElement(); | ||
1576 | |||
1577 | return id; | ||
1578 | } | ||
1579 | |||
1580 | public static Vector3 ReadVector(XmlTextReader reader, string name) | ||
1581 | { | ||
1582 | Vector3 vec; | ||
1583 | |||
1584 | reader.ReadStartElement(name); | ||
1585 | vec.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // X or x | ||
1586 | vec.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Y or y | ||
1587 | vec.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Z or z | ||
1588 | reader.ReadEndElement(); | ||
1589 | |||
1590 | return vec; | ||
1591 | } | ||
1592 | |||
1593 | public static Quaternion ReadQuaternion(XmlTextReader reader, string name) | ||
1594 | { | ||
1595 | Quaternion quat = new Quaternion(); | ||
1596 | |||
1597 | reader.ReadStartElement(name); | ||
1598 | while (reader.NodeType != XmlNodeType.EndElement) | ||
1599 | { | ||
1600 | switch (reader.Name.ToLower()) | ||
1601 | { | ||
1602 | case "x": | ||
1603 | quat.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty); | ||
1604 | break; | ||
1605 | case "y": | ||
1606 | quat.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty); | ||
1607 | break; | ||
1608 | case "z": | ||
1609 | quat.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty); | ||
1610 | break; | ||
1611 | case "w": | ||
1612 | quat.W = reader.ReadElementContentAsFloat(reader.Name, String.Empty); | ||
1613 | break; | ||
1614 | } | ||
1615 | } | ||
1616 | |||
1617 | reader.ReadEndElement(); | ||
1618 | |||
1619 | return quat; | ||
1620 | } | ||
1621 | |||
1561 | } | 1622 | } |
1562 | } | 1623 | } |