private static string GetStringFromObject( object o )
{
if ( o == null )
{
return "-null-";
}
else if ( o is string )
{
return String.Format( "\"{0}\"", (string)o );
}
else if ( o is bool )
{
return o.ToString();
}
else if ( o is char )
{
return String.Format( "0x{0:X} '{1}'", (int)(char)o, (char)o );
}
else if ( o is Serial )
{
Serial s = (Serial)o;
if ( s.IsValid )
{
if ( s.IsItem )
{
return String.Format( "(I) 0x{0:X}", s.Value );
}
else if ( s.IsMobile )
{
return String.Format( "(M) 0x{0:X}", s.Value );
}
}
return String.Format( "(?) 0x{0:X}", s.Value );
}
else if ( o is byte || o is sbyte || o is short || o is ushort || o is int || o is uint || o is long || o is ulong )
{
return String.Format( "{0} (0x{0:X})", o );
}
else if ( o is Mobile )
{
return String.Format( "(M) 0x{0:X} \"{1}\"", ((Mobile)o).Serial.Value, ((Mobile)o).Name );
}
else if ( o is Item )
{
return String.Format( "(I) 0x{0:X}", ((Item)o).Serial );
}
else if ( o is Type )
{
return ((Type)o).Name;
}
else
{
return o.ToString();
}
}