diff options
author | Adam Frisby | 2008-04-21 09:12:47 +0000 |
---|---|---|
committer | Adam Frisby | 2008-04-21 09:12:47 +0000 |
commit | f741a62d540f0c04eedebd9c7eb072fc50c4a111 (patch) | |
tree | f94ce4b084c538feb450dc5827358d231da37dbe /OpenSim/Region/Environment/Modules/ModuleFramework/Commander.cs | |
parent | Update svn properties. (diff) | |
download | opensim-SC-f741a62d540f0c04eedebd9c7eb072fc50c4a111.zip opensim-SC-f741a62d540f0c04eedebd9c7eb072fc50c4a111.tar.gz opensim-SC-f741a62d540f0c04eedebd9c7eb072fc50c4a111.tar.bz2 opensim-SC-f741a62d540f0c04eedebd9c7eb072fc50c4a111.tar.xz |
* 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.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Modules/ModuleFramework/Commander.cs | 58 |
1 files changed, 33 insertions, 25 deletions
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 | |||
42 | public class Command : ICommand | 42 | public class Command : ICommand |
43 | { | 43 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | private List<CommandArgument> m_args = new List<CommandArgument>(); | ||
45 | 46 | ||
46 | private Action<object[]> m_command; | 47 | private Action<object[]> m_command; |
47 | private string m_name; | ||
48 | private string m_help; | 48 | private string m_help; |
49 | private List<CommandArgument> m_args = new List<CommandArgument>(); | 49 | private string m_name; |
50 | 50 | ||
51 | public Command(string name, Action<Object[]> command, string help) | 51 | public Command(string name, Action<Object[]> command, string help) |
52 | { | 52 | { |
@@ -55,6 +55,8 @@ namespace OpenSim.Region.Environment.Modules.ModuleFramework | |||
55 | m_help = help; | 55 | m_help = help; |
56 | } | 56 | } |
57 | 57 | ||
58 | #region ICommand Members | ||
59 | |||
58 | public void AddArgument(string name, string helptext, string type) | 60 | public void AddArgument(string name, string helptext, string type) |
59 | { | 61 | { |
60 | m_args.Add(new CommandArgument(name, helptext, type)); | 62 | m_args.Add(new CommandArgument(name, helptext, type)); |
@@ -143,8 +145,8 @@ namespace OpenSim.Region.Environment.Modules.ModuleFramework | |||
143 | catch (FormatException) | 145 | catch (FormatException) |
144 | { | 146 | { |
145 | m_log.Error("Argument number " + (i + 1) + | 147 | m_log.Error("Argument number " + (i + 1) + |
146 | " (" + m_args[i].Name + ") must be a valid " + | 148 | " (" + m_args[i].Name + ") must be a valid " + |
147 | m_args[i].ArgumentType.ToLower() + "."); | 149 | m_args[i].ArgumentType.ToLower() + "."); |
148 | } | 150 | } |
149 | cleanArgs[i] = m_args[i].ArgumentValue; | 151 | cleanArgs[i] = m_args[i].ArgumentValue; |
150 | 152 | ||
@@ -153,6 +155,8 @@ namespace OpenSim.Region.Environment.Modules.ModuleFramework | |||
153 | 155 | ||
154 | m_command.Invoke(cleanArgs); | 156 | m_command.Invoke(cleanArgs); |
155 | } | 157 | } |
158 | |||
159 | #endregion | ||
156 | } | 160 | } |
157 | 161 | ||
158 | /// <summary> | 162 | /// <summary> |
@@ -160,8 +164,8 @@ namespace OpenSim.Region.Environment.Modules.ModuleFramework | |||
160 | /// </summary> | 164 | /// </summary> |
161 | public class CommandArgument | 165 | public class CommandArgument |
162 | { | 166 | { |
163 | private string m_name; | ||
164 | private string m_help; | 167 | private string m_help; |
168 | private string m_name; | ||
165 | private string m_type; | 169 | private string m_type; |
166 | private Object m_val; | 170 | private Object m_val; |
167 | 171 | ||
@@ -208,29 +212,13 @@ namespace OpenSim.Region.Environment.Modules.ModuleFramework | |||
208 | m_name = name; | 212 | m_name = name; |
209 | } | 213 | } |
210 | 214 | ||
215 | #region ICommander Members | ||
216 | |||
211 | public void RegisterCommand(string commandName, ICommand command) | 217 | public void RegisterCommand(string commandName, ICommand command) |
212 | { | 218 | { |
213 | m_commands[commandName] = command; | 219 | m_commands[commandName] = command; |
214 | } | 220 | } |
215 | 221 | ||
216 | void ShowConsoleHelp() | ||
217 | { | ||
218 | m_log.Info("===" + m_name + "==="); | ||
219 | foreach (ICommand com in m_commands.Values) | ||
220 | { | ||
221 | m_log.Info("* " + com.Name + " - " + com.Help); | ||
222 | } | ||
223 | } | ||
224 | |||
225 | string EscapeRuntimeAPICommand(string command) | ||
226 | { | ||
227 | command = command.Replace('-', '_'); | ||
228 | StringBuilder tmp = new StringBuilder(command); | ||
229 | tmp[0] = tmp[0].ToString().ToUpper().ToCharArray()[0]; | ||
230 | |||
231 | return tmp.ToString(); | ||
232 | } | ||
233 | |||
234 | /// <summary> | 222 | /// <summary> |
235 | /// Generates a runtime C# class which can be compiled and inserted via reflection to enable modules to register new script commands | 223 | /// Generates a runtime C# class which can be compiled and inserted via reflection to enable modules to register new script commands |
236 | /// </summary> | 224 | /// </summary> |
@@ -253,7 +241,7 @@ namespace OpenSim.Region.Environment.Modules.ModuleFramework | |||
253 | { | 241 | { |
254 | classSrc += "\t\targs[" + i.ToString() + "] = " + Util.Md5Hash(arg.Key) + " " + ";\n"; | 242 | classSrc += "\t\targs[" + i.ToString() + "] = " + Util.Md5Hash(arg.Key) + " " + ";\n"; |
255 | i++; | 243 | i++; |
256 | } | 244 | } |
257 | classSrc += "\t\tGetCommander(\"" + m_name + "\").Run(\"" + com.Name + "\", args);\n"; | 245 | classSrc += "\t\tGetCommander(\"" + m_name + "\").Run(\"" + com.Name + "\", args);\n"; |
258 | classSrc += "\t}\n"; | 246 | classSrc += "\t}\n"; |
259 | } | 247 | } |
@@ -296,5 +284,25 @@ namespace OpenSim.Region.Environment.Modules.ModuleFramework | |||
296 | ShowConsoleHelp(); | 284 | ShowConsoleHelp(); |
297 | } | 285 | } |
298 | } | 286 | } |
287 | |||
288 | #endregion | ||
289 | |||
290 | private void ShowConsoleHelp() | ||
291 | { | ||
292 | m_log.Info("===" + m_name + "==="); | ||
293 | foreach (ICommand com in m_commands.Values) | ||
294 | { | ||
295 | m_log.Info("* " + com.Name + " - " + com.Help); | ||
296 | } | ||
297 | } | ||
298 | |||
299 | private string EscapeRuntimeAPICommand(string command) | ||
300 | { | ||
301 | command = command.Replace('-', '_'); | ||
302 | StringBuilder tmp = new StringBuilder(command); | ||
303 | tmp[0] = tmp[0].ToString().ToUpper().ToCharArray()[0]; | ||
304 | |||
305 | return tmp.ToString(); | ||
306 | } | ||
299 | } | 307 | } |
300 | } | 308 | } \ No newline at end of file |