mirror of
https://github.com/opensim/opensim.git
synced 2026-08-07 17:55:48 +08:00
Merge branch 'master' into careminster-presence-refactor
Also prevent god takes from ending up in Lost and Found
This commit is contained in:
@@ -1558,5 +1558,86 @@ namespace OpenSim.Framework
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
#region Xml Serialization Utilities
|
||||
public static bool ReadBoolean(XmlTextReader reader)
|
||||
{
|
||||
reader.ReadStartElement();
|
||||
bool result = Boolean.Parse(reader.ReadContentAsString().ToLower());
|
||||
reader.ReadEndElement();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static UUID ReadUUID(XmlTextReader reader, string name)
|
||||
{
|
||||
UUID id;
|
||||
string idStr;
|
||||
|
||||
reader.ReadStartElement(name);
|
||||
|
||||
if (reader.Name == "Guid")
|
||||
idStr = reader.ReadElementString("Guid");
|
||||
else if (reader.Name == "UUID")
|
||||
idStr = reader.ReadElementString("UUID");
|
||||
else // no leading tag
|
||||
idStr = reader.ReadContentAsString();
|
||||
UUID.TryParse(idStr, out id);
|
||||
reader.ReadEndElement();
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
public static Vector3 ReadVector(XmlTextReader reader, string name)
|
||||
{
|
||||
Vector3 vec;
|
||||
|
||||
reader.ReadStartElement(name);
|
||||
vec.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // X or x
|
||||
vec.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Y or y
|
||||
vec.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Z or z
|
||||
reader.ReadEndElement();
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
public static Quaternion ReadQuaternion(XmlTextReader reader, string name)
|
||||
{
|
||||
Quaternion quat = new Quaternion();
|
||||
|
||||
reader.ReadStartElement(name);
|
||||
while (reader.NodeType != XmlNodeType.EndElement)
|
||||
{
|
||||
switch (reader.Name.ToLower())
|
||||
{
|
||||
case "x":
|
||||
quat.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
|
||||
break;
|
||||
case "y":
|
||||
quat.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
|
||||
break;
|
||||
case "z":
|
||||
quat.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
|
||||
break;
|
||||
case "w":
|
||||
quat.W = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
reader.ReadEndElement();
|
||||
|
||||
return quat;
|
||||
}
|
||||
|
||||
public static T ReadEnum<T>(XmlTextReader reader, string name)
|
||||
{
|
||||
string value = reader.ReadElementContentAsString(name, String.Empty);
|
||||
// !!!!! to deal with flags without commas
|
||||
if (value.Contains(" ") && !value.Contains(","))
|
||||
value = value.Replace(" ", ", ");
|
||||
|
||||
return (T)Enum.Parse(typeof(T), value); ;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user