Files
libremetaverse/libsecondlife/examples/TestClient/Commands/ExportOutfitCommand.cs
bushing 6d289162a8 more eol-style fixes
git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@1161 52acb1d6-8a22-11de-b505-999d5b087335
2007-04-28 20:54:02 +00:00

66 lines
1.7 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
{
public ExportOutfitCommand(TestClient 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 (Client.Appearances)
{
if (Client.Appearances.ContainsKey(id))
{
try
{
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
XmlWriter writer = XmlWriter.Create(args[1], settings);
try
{
Client.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();
}
}
}
}
}