Files
libremetaverse/libsecondlife-cs/examples/TestClient/Commands/ExportOutfitCommand.cs
John Hurliman 1788cb1d22 * Refactored TestClient, all Commands now have a reference to the SecondLife class that is in charge of them
* ExportCommand will only export objects owned by the bot (will add master support soon)
* libsecondlife.Tests project file references the latest available NUnit

git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@748 52acb1d6-8a22-11de-b505-999d5b087335
2006-12-21 08:53:08 +00:00

72 lines
1.9 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using libsecondlife;
using libsecondlife.Packets;
namespace libsecondlife.TestClient
{
public class ExportOutfitCommand : Command
{
SecondLife Client;
public ExportOutfitCommand(TestClient testClient)
{
TestClient = testClient;
Client = (SecondLife)TestClient;
Name = "exportoutfit";
Description = "Exports an avatars outfit to an xml file. Usage: exportoutfit avataruuid outputfile.xml";
}
public override string Execute(string[] args, LLUUID fromAgentID)
{
if (args.Length != 2)
return "Usage: exportoutfit avataruuid outputfile.xml";
LLUUID id;
try
{
id = new LLUUID(args[0]);
}
catch (Exception)
{
return "Usage: exportoutfit avataruuid outputfile.xml";
}
lock (TestClient.Appearances)
{
if (TestClient.Appearances.ContainsKey(id))
{
try
{
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
XmlWriter writer = XmlWriter.Create(args[1], settings);
try
{
TestClient.Appearances[id].ToXml(writer);
}
finally
{
writer.Close();
}
}
catch (Exception e)
{
return e.ToString();
}
return "Exported appearance for avatar " + id.ToString() + " to " + args[1];
}
else
{
return "Couldn't find an appearance for avatar " + id.ToString();
}
}
}
}
}