From f741a62d540f0c04eedebd9c7eb072fc50c4a111 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Mon, 21 Apr 2008 09:12:47 +0000 Subject: * Formatted ExportSerialiserModule and SvnBackupModule * Added a form of GZip compression support to object.xml files produced by exportserialiser. Will look towards standard GZip support. File compression seems to be highly worthwhile reducing a 1.5mb sim state to 62kb. --- .../Modules/ModuleFramework/Commander.cs | 58 ++++++++++++---------- 1 file changed, 33 insertions(+), 25 deletions(-) (limited to 'OpenSim/Region/Environment/Modules/ModuleFramework') diff --git a/OpenSim/Region/Environment/Modules/ModuleFramework/Commander.cs b/OpenSim/Region/Environment/Modules/ModuleFramework/Commander.cs index 27d73b5..7ef087d 100644 --- a/OpenSim/Region/Environment/Modules/ModuleFramework/Commander.cs +++ b/OpenSim/Region/Environment/Modules/ModuleFramework/Commander.cs @@ -42,11 +42,11 @@ namespace OpenSim.Region.Environment.Modules.ModuleFramework public class Command : ICommand { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private List m_args = new List(); private Action m_command; - private string m_name; private string m_help; - private List m_args = new List(); + private string m_name; public Command(string name, Action command, string help) { @@ -55,6 +55,8 @@ namespace OpenSim.Region.Environment.Modules.ModuleFramework m_help = help; } + #region ICommand Members + public void AddArgument(string name, string helptext, string type) { m_args.Add(new CommandArgument(name, helptext, type)); @@ -143,8 +145,8 @@ namespace OpenSim.Region.Environment.Modules.ModuleFramework catch (FormatException) { m_log.Error("Argument number " + (i + 1) + - " (" + m_args[i].Name + ") must be a valid " + - m_args[i].ArgumentType.ToLower() + "."); + " (" + m_args[i].Name + ") must be a valid " + + m_args[i].ArgumentType.ToLower() + "."); } cleanArgs[i] = m_args[i].ArgumentValue; @@ -153,6 +155,8 @@ namespace OpenSim.Region.Environment.Modules.ModuleFramework m_command.Invoke(cleanArgs); } + + #endregion } /// @@ -160,8 +164,8 @@ namespace OpenSim.Region.Environment.Modules.ModuleFramework /// public class CommandArgument { - private string m_name; private string m_help; + private string m_name; private string m_type; private Object m_val; @@ -208,29 +212,13 @@ namespace OpenSim.Region.Environment.Modules.ModuleFramework m_name = name; } + #region ICommander Members + public void RegisterCommand(string commandName, ICommand command) { m_commands[commandName] = command; } - void ShowConsoleHelp() - { - m_log.Info("===" + m_name + "==="); - foreach (ICommand com in m_commands.Values) - { - m_log.Info("* " + com.Name + " - " + com.Help); - } - } - - string EscapeRuntimeAPICommand(string command) - { - command = command.Replace('-', '_'); - StringBuilder tmp = new StringBuilder(command); - tmp[0] = tmp[0].ToString().ToUpper().ToCharArray()[0]; - - return tmp.ToString(); - } - /// /// Generates a runtime C# class which can be compiled and inserted via reflection to enable modules to register new script commands /// @@ -253,7 +241,7 @@ namespace OpenSim.Region.Environment.Modules.ModuleFramework { classSrc += "\t\targs[" + i.ToString() + "] = " + Util.Md5Hash(arg.Key) + " " + ";\n"; i++; - } + } classSrc += "\t\tGetCommander(\"" + m_name + "\").Run(\"" + com.Name + "\", args);\n"; classSrc += "\t}\n"; } @@ -296,5 +284,25 @@ namespace OpenSim.Region.Environment.Modules.ModuleFramework ShowConsoleHelp(); } } + + #endregion + + private void ShowConsoleHelp() + { + m_log.Info("===" + m_name + "==="); + foreach (ICommand com in m_commands.Values) + { + m_log.Info("* " + com.Name + " - " + com.Help); + } + } + + private string EscapeRuntimeAPICommand(string command) + { + command = command.Replace('-', '_'); + StringBuilder tmp = new StringBuilder(command); + tmp[0] = tmp[0].ToString().ToUpper().ToCharArray()[0]; + + return tmp.ToString(); + } } -} +} \ No newline at end of file -- cgit v1.1