* Debugging some inventory related NullRefException's.

0.6.5-rc1
Adam Frisby 2009-05-10 20:50:38 +00:00
parent 53a350573e
commit 2d4166fecf
1 changed files with 29 additions and 20 deletions

View File

@ -66,28 +66,37 @@ namespace OpenSim.Framework.Communications.Capabilities
FieldInfo[] fields = myType.GetFields(); FieldInfo[] fields = myType.GetFields();
for (int i = 0; i < fields.Length; i++) for (int i = 0; i < fields.Length; i++)
{ {
object fieldValue = fields[i].GetValue(obj); try
LLSDType[] fieldAttributes =
(LLSDType[]) fieldValue.GetType().GetCustomAttributes(typeof (LLSDType), false);
if (fieldAttributes.Length > 0)
{ {
writer.WriteStartElement(String.Empty, "key", String.Empty); object fieldValue = fields[i].GetValue(obj);
string fieldName = fields[i].Name; LLSDType[] fieldAttributes =
fieldName = fieldName.Replace("___", "-"); (LLSDType[]) fieldValue.GetType().GetCustomAttributes(typeof (LLSDType), false);
writer.WriteString(fieldName); if (fieldAttributes.Length > 0)
writer.WriteEndElement(); {
SerializeOSDType(writer, fieldValue); writer.WriteStartElement(String.Empty, "key", String.Empty);
} string fieldName = fields[i].Name;
else fieldName = fieldName.Replace("___", "-");
writer.WriteString(fieldName);
writer.WriteEndElement();
SerializeOSDType(writer, fieldValue);
}
else
{
writer.WriteStartElement(String.Empty, "key", String.Empty);
string fieldName = fields[i].Name;
fieldName = fieldName.Replace("___", "-");
writer.WriteString(fieldName);
writer.WriteEndElement();
LLSD.LLSDWriteOne(writer, fieldValue);
// OpenMetaverse.StructuredData.LLSDParser.SerializeXmlElement(
// writer, OpenMetaverse.StructuredData.OSD.FromObject(fieldValue));
}
} catch(NullReferenceException e)
{ {
writer.WriteStartElement(String.Empty, "key", String.Empty); System.Console.WriteLine("-----------NRE-------------");
string fieldName = fields[i].Name; System.Console.WriteLine("Type: " + fields[i].GetValue(obj).GetType().FullName);
fieldName = fieldName.Replace("___", "-"); System.Console.WriteLine("-----------NRE-------------");
writer.WriteString(fieldName); throw;
writer.WriteEndElement();
LLSD.LLSDWriteOne(writer, fieldValue);
// OpenMetaverse.StructuredData.LLSDParser.SerializeXmlElement(
// writer, OpenMetaverse.StructuredData.OSD.FromObject(fieldValue));
} }
} }
writer.WriteEndElement(); writer.WriteEndElement();