diff options
author | Jeff Ames | 2008-05-04 21:59:29 +0000 |
---|---|---|
committer | Jeff Ames | 2008-05-04 21:59:29 +0000 |
commit | 0e31eb831409c7f2f9f1ba88dec13dfef4dd3ac1 (patch) | |
tree | 964fa5d80d3910c3aa51cdd62f03e2779791abe2 /OpenSim/Region/Environment/Modules/Framework | |
parent | * Reformatted EstateManagementModule (diff) | |
download | opensim-SC-0e31eb831409c7f2f9f1ba88dec13dfef4dd3ac1.zip opensim-SC-0e31eb831409c7f2f9f1ba88dec13dfef4dd3ac1.tar.gz opensim-SC-0e31eb831409c7f2f9f1ba88dec13dfef4dd3ac1.tar.bz2 opensim-SC-0e31eb831409c7f2f9f1ba88dec13dfef4dd3ac1.tar.xz |
Update svn properties.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Framework')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Commander.cs | 624 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/CommanderTestModule.cs | 176 |
2 files changed, 400 insertions, 400 deletions
diff --git a/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Commander.cs b/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Commander.cs index f9896bd..84487e8 100644 --- a/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Commander.cs +++ b/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/Commander.cs | |||
@@ -1,313 +1,313 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Text; | 31 | using System.Text; |
32 | using log4net; | 32 | using log4net; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Region.Environment.Interfaces; | 34 | using OpenSim.Region.Environment.Interfaces; |
35 | 35 | ||
36 | namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander | 36 | namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander |
37 | { | 37 | { |
38 | /// <summary> | 38 | /// <summary> |
39 | /// A single function call encapsulated in a class which enforces arguments when passing around as Object[]'s. | 39 | /// A single function call encapsulated in a class which enforces arguments when passing around as Object[]'s. |
40 | /// Used for console commands and script API generation | 40 | /// Used for console commands and script API generation |
41 | /// </summary> | 41 | /// </summary> |
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 | private List<CommandArgument> m_args = new List<CommandArgument>(); |
46 | 46 | ||
47 | private Action<object[]> m_command; | 47 | private Action<object[]> m_command; |
48 | private string m_help; | 48 | private string m_help; |
49 | private string m_name; | 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 | { |
53 | m_name = name; | 53 | m_name = name; |
54 | m_command = command; | 54 | m_command = command; |
55 | m_help = help; | 55 | m_help = help; |
56 | } | 56 | } |
57 | 57 | ||
58 | #region ICommand Members | 58 | #region ICommand Members |
59 | 59 | ||
60 | public void AddArgument(string name, string helptext, string type) | 60 | public void AddArgument(string name, string helptext, string type) |
61 | { | 61 | { |
62 | m_args.Add(new CommandArgument(name, helptext, type)); | 62 | m_args.Add(new CommandArgument(name, helptext, type)); |
63 | } | 63 | } |
64 | 64 | ||
65 | public string Name | 65 | public string Name |
66 | { | 66 | { |
67 | get { return m_name; } | 67 | get { return m_name; } |
68 | } | 68 | } |
69 | 69 | ||
70 | public string Help | 70 | public string Help |
71 | { | 71 | { |
72 | get { return m_help; } | 72 | get { return m_help; } |
73 | } | 73 | } |
74 | 74 | ||
75 | public Dictionary<string, string> Arguments | 75 | public Dictionary<string, string> Arguments |
76 | { | 76 | { |
77 | get | 77 | get |
78 | { | 78 | { |
79 | Dictionary<string, string> tmp = new Dictionary<string, string>(); | 79 | Dictionary<string, string> tmp = new Dictionary<string, string>(); |
80 | foreach (CommandArgument arg in m_args) | 80 | foreach (CommandArgument arg in m_args) |
81 | { | 81 | { |
82 | tmp.Add(arg.Name, arg.ArgumentType); | 82 | tmp.Add(arg.Name, arg.ArgumentType); |
83 | } | 83 | } |
84 | return tmp; | 84 | return tmp; |
85 | } | 85 | } |
86 | } | 86 | } |
87 | 87 | ||
88 | public void ShowConsoleHelp() | 88 | public void ShowConsoleHelp() |
89 | { | 89 | { |
90 | m_log.Info("== " + Name + " =="); | 90 | m_log.Info("== " + Name + " =="); |
91 | m_log.Info(m_help); | 91 | m_log.Info(m_help); |
92 | m_log.Info("= Parameters ="); | 92 | m_log.Info("= Parameters ="); |
93 | foreach (CommandArgument arg in m_args) | 93 | foreach (CommandArgument arg in m_args) |
94 | { | 94 | { |
95 | m_log.Info("* " + arg.Name + " (" + arg.ArgumentType + ")"); | 95 | m_log.Info("* " + arg.Name + " (" + arg.ArgumentType + ")"); |
96 | m_log.Info("\t" + arg.HelpText); | 96 | m_log.Info("\t" + arg.HelpText); |
97 | } | 97 | } |
98 | } | 98 | } |
99 | 99 | ||
100 | public void Run(Object[] args) | 100 | public void Run(Object[] args) |
101 | { | 101 | { |
102 | Object[] cleanArgs = new Object[m_args.Count]; | 102 | Object[] cleanArgs = new Object[m_args.Count]; |
103 | 103 | ||
104 | if (args.Length < cleanArgs.Length) | 104 | if (args.Length < cleanArgs.Length) |
105 | { | 105 | { |
106 | m_log.Error("Missing " + (cleanArgs.Length - args.Length) + " argument(s)"); | 106 | m_log.Error("Missing " + (cleanArgs.Length - args.Length) + " argument(s)"); |
107 | ShowConsoleHelp(); | 107 | ShowConsoleHelp(); |
108 | return; | 108 | return; |
109 | } | 109 | } |
110 | if (args.Length > cleanArgs.Length) | 110 | if (args.Length > cleanArgs.Length) |
111 | { | 111 | { |
112 | m_log.Error("Too many arguments for this command. Type '<module> <command> help' for help."); | 112 | m_log.Error("Too many arguments for this command. Type '<module> <command> help' for help."); |
113 | return; | 113 | return; |
114 | } | 114 | } |
115 | 115 | ||
116 | int i = 0; | 116 | int i = 0; |
117 | foreach (Object arg in args) | 117 | foreach (Object arg in args) |
118 | { | 118 | { |
119 | if (string.IsNullOrEmpty(arg.ToString())) | 119 | if (string.IsNullOrEmpty(arg.ToString())) |
120 | { | 120 | { |
121 | m_log.Error("Empty arguments are not allowed"); | 121 | m_log.Error("Empty arguments are not allowed"); |
122 | return; | 122 | return; |
123 | } | 123 | } |
124 | try | 124 | try |
125 | { | 125 | { |
126 | switch (m_args[i].ArgumentType) | 126 | switch (m_args[i].ArgumentType) |
127 | { | 127 | { |
128 | case "String": | 128 | case "String": |
129 | m_args[i].ArgumentValue = arg.ToString(); | 129 | m_args[i].ArgumentValue = arg.ToString(); |
130 | break; | 130 | break; |
131 | case "Integer": | 131 | case "Integer": |
132 | m_args[i].ArgumentValue = Int32.Parse(arg.ToString()); | 132 | m_args[i].ArgumentValue = Int32.Parse(arg.ToString()); |
133 | break; | 133 | break; |
134 | case "Double": | 134 | case "Double": |
135 | m_args[i].ArgumentValue = Double.Parse(arg.ToString()); | 135 | m_args[i].ArgumentValue = Double.Parse(arg.ToString()); |
136 | break; | 136 | break; |
137 | case "Boolean": | 137 | case "Boolean": |
138 | m_args[i].ArgumentValue = Boolean.Parse(arg.ToString()); | 138 | m_args[i].ArgumentValue = Boolean.Parse(arg.ToString()); |
139 | break; | 139 | break; |
140 | default: | 140 | default: |
141 | m_log.Error("Unknown desired type for argument " + m_args[i].Name + " on command " + m_name); | 141 | m_log.Error("Unknown desired type for argument " + m_args[i].Name + " on command " + m_name); |
142 | break; | 142 | break; |
143 | } | 143 | } |
144 | } | 144 | } |
145 | catch (FormatException) | 145 | catch (FormatException) |
146 | { | 146 | { |
147 | m_log.Error("Argument number " + (i + 1) + | 147 | m_log.Error("Argument number " + (i + 1) + |
148 | " (" + m_args[i].Name + ") must be a valid " + | 148 | " (" + m_args[i].Name + ") must be a valid " + |
149 | m_args[i].ArgumentType.ToLower() + "."); | 149 | m_args[i].ArgumentType.ToLower() + "."); |
150 | } | 150 | } |
151 | cleanArgs[i] = m_args[i].ArgumentValue; | 151 | cleanArgs[i] = m_args[i].ArgumentValue; |
152 | 152 | ||
153 | i++; | 153 | i++; |
154 | } | 154 | } |
155 | 155 | ||
156 | m_command.Invoke(cleanArgs); | 156 | m_command.Invoke(cleanArgs); |
157 | } | 157 | } |
158 | 158 | ||
159 | #endregion | 159 | #endregion |
160 | } | 160 | } |
161 | 161 | ||
162 | /// <summary> | 162 | /// <summary> |
163 | /// A single command argument, contains name, type and at runtime, value. | 163 | /// A single command argument, contains name, type and at runtime, value. |
164 | /// </summary> | 164 | /// </summary> |
165 | public class CommandArgument | 165 | public class CommandArgument |
166 | { | 166 | { |
167 | private string m_help; | 167 | private string m_help; |
168 | private string m_name; | 168 | private string m_name; |
169 | private string m_type; | 169 | private string m_type; |
170 | private Object m_val; | 170 | private Object m_val; |
171 | 171 | ||
172 | public CommandArgument(string name, string help, string type) | 172 | public CommandArgument(string name, string help, string type) |
173 | { | 173 | { |
174 | m_name = name; | 174 | m_name = name; |
175 | m_help = help; | 175 | m_help = help; |
176 | m_type = type; | 176 | m_type = type; |
177 | } | 177 | } |
178 | 178 | ||
179 | public string Name | 179 | public string Name |
180 | { | 180 | { |
181 | get { return m_name; } | 181 | get { return m_name; } |
182 | } | 182 | } |
183 | 183 | ||
184 | public string HelpText | 184 | public string HelpText |
185 | { | 185 | { |
186 | get { return m_help; } | 186 | get { return m_help; } |
187 | } | 187 | } |
188 | 188 | ||
189 | public string ArgumentType | 189 | public string ArgumentType |
190 | { | 190 | { |
191 | get { return m_type; } | 191 | get { return m_type; } |
192 | } | 192 | } |
193 | 193 | ||
194 | public Object ArgumentValue | 194 | public Object ArgumentValue |
195 | { | 195 | { |
196 | get { return m_val; } | 196 | get { return m_val; } |
197 | set { m_val = value; } | 197 | set { m_val = value; } |
198 | } | 198 | } |
199 | } | 199 | } |
200 | 200 | ||
201 | /// <summary> | 201 | /// <summary> |
202 | /// A class to enable modules to register console and script commands, which enforces typing and valid input. | 202 | /// A class to enable modules to register console and script commands, which enforces typing and valid input. |
203 | /// </summary> | 203 | /// </summary> |
204 | public class Commander : ICommander | 204 | public class Commander : ICommander |
205 | { | 205 | { |
206 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 206 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
207 | private Dictionary<string, ICommand> m_commands = new Dictionary<string, ICommand>(); | 207 | private Dictionary<string, ICommand> m_commands = new Dictionary<string, ICommand>(); |
208 | private string m_name; | 208 | private string m_name; |
209 | 209 | ||
210 | public Commander(string name) | 210 | public Commander(string name) |
211 | { | 211 | { |
212 | m_name = name; | 212 | m_name = name; |
213 | } | 213 | } |
214 | 214 | ||
215 | public Dictionary<string, ICommand> Commands | 215 | public Dictionary<string, ICommand> Commands |
216 | { | 216 | { |
217 | get { return m_commands; } | 217 | get { return m_commands; } |
218 | } | 218 | } |
219 | 219 | ||
220 | #region ICommander Members | 220 | #region ICommander Members |
221 | 221 | ||
222 | public void RegisterCommand(string commandName, ICommand command) | 222 | public void RegisterCommand(string commandName, ICommand command) |
223 | { | 223 | { |
224 | m_commands[commandName] = command; | 224 | m_commands[commandName] = command; |
225 | } | 225 | } |
226 | 226 | ||
227 | /// <summary> | 227 | /// <summary> |
228 | /// Generates a runtime C# class which can be compiled and inserted via reflection to enable modules to register new script commands | 228 | /// Generates a runtime C# class which can be compiled and inserted via reflection to enable modules to register new script commands |
229 | /// </summary> | 229 | /// </summary> |
230 | /// <returns>Returns C# source code to create a binding</returns> | 230 | /// <returns>Returns C# source code to create a binding</returns> |
231 | public string GenerateRuntimeAPI() | 231 | public string GenerateRuntimeAPI() |
232 | { | 232 | { |
233 | string classSrc = "\n\tpublic class " + m_name + " {\n"; | 233 | string classSrc = "\n\tpublic class " + m_name + " {\n"; |
234 | foreach (ICommand com in m_commands.Values) | 234 | foreach (ICommand com in m_commands.Values) |
235 | { | 235 | { |
236 | classSrc += "\tpublic void " + EscapeRuntimeAPICommand(com.Name) + "( "; | 236 | classSrc += "\tpublic void " + EscapeRuntimeAPICommand(com.Name) + "( "; |
237 | foreach (KeyValuePair<string, string> arg in com.Arguments) | 237 | foreach (KeyValuePair<string, string> arg in com.Arguments) |
238 | { | 238 | { |
239 | classSrc += arg.Value + " " + Util.Md5Hash(arg.Key) + ","; | 239 | classSrc += arg.Value + " " + Util.Md5Hash(arg.Key) + ","; |
240 | } | 240 | } |
241 | classSrc = classSrc.Remove(classSrc.Length - 1); // Delete the last comma | 241 | classSrc = classSrc.Remove(classSrc.Length - 1); // Delete the last comma |
242 | classSrc += " )\n\t{\n"; | 242 | classSrc += " )\n\t{\n"; |
243 | classSrc += "\t\tObject[] args = new Object[" + com.Arguments.Count.ToString() + "];\n"; | 243 | classSrc += "\t\tObject[] args = new Object[" + com.Arguments.Count.ToString() + "];\n"; |
244 | int i = 0; | 244 | int i = 0; |
245 | foreach (KeyValuePair<string, string> arg in com.Arguments) | 245 | foreach (KeyValuePair<string, string> arg in com.Arguments) |
246 | { | 246 | { |
247 | classSrc += "\t\targs[" + i.ToString() + "] = " + Util.Md5Hash(arg.Key) + " " + ";\n"; | 247 | classSrc += "\t\targs[" + i.ToString() + "] = " + Util.Md5Hash(arg.Key) + " " + ";\n"; |
248 | i++; | 248 | i++; |
249 | } | 249 | } |
250 | classSrc += "\t\tGetCommander(\"" + m_name + "\").Run(\"" + com.Name + "\", args);\n"; | 250 | classSrc += "\t\tGetCommander(\"" + m_name + "\").Run(\"" + com.Name + "\", args);\n"; |
251 | classSrc += "\t}\n"; | 251 | classSrc += "\t}\n"; |
252 | } | 252 | } |
253 | classSrc += "}\n"; | 253 | classSrc += "}\n"; |
254 | 254 | ||
255 | return classSrc; | 255 | return classSrc; |
256 | } | 256 | } |
257 | 257 | ||
258 | /// <summary> | 258 | /// <summary> |
259 | /// Runs a specified function with attached arguments | 259 | /// Runs a specified function with attached arguments |
260 | /// *** <b>DO NOT CALL DIRECTLY.</b> *** | 260 | /// *** <b>DO NOT CALL DIRECTLY.</b> *** |
261 | /// Call ProcessConsoleCommand instead if handling human input. | 261 | /// Call ProcessConsoleCommand instead if handling human input. |
262 | /// </summary> | 262 | /// </summary> |
263 | /// <param name="function">The function name to call</param> | 263 | /// <param name="function">The function name to call</param> |
264 | /// <param name="args">The function parameters</param> | 264 | /// <param name="args">The function parameters</param> |
265 | public void Run(string function, object[] args) | 265 | public void Run(string function, object[] args) |
266 | { | 266 | { |
267 | m_commands[function].Run(args); | 267 | m_commands[function].Run(args); |
268 | } | 268 | } |
269 | 269 | ||
270 | public void ProcessConsoleCommand(string function, string[] args) | 270 | public void ProcessConsoleCommand(string function, string[] args) |
271 | { | 271 | { |
272 | if (m_commands.ContainsKey(function)) | 272 | if (m_commands.ContainsKey(function)) |
273 | { | 273 | { |
274 | if (args.Length > 0 && args[0] == "help") | 274 | if (args.Length > 0 && args[0] == "help") |
275 | { | 275 | { |
276 | m_commands[function].ShowConsoleHelp(); | 276 | m_commands[function].ShowConsoleHelp(); |
277 | } | 277 | } |
278 | else | 278 | else |
279 | { | 279 | { |
280 | m_commands[function].Run(args); | 280 | m_commands[function].Run(args); |
281 | } | 281 | } |
282 | } | 282 | } |
283 | else | 283 | else |
284 | { | 284 | { |
285 | if (function != "help") | 285 | if (function != "help") |
286 | m_log.Error("Invalid command - No such command exists"); | 286 | m_log.Error("Invalid command - No such command exists"); |
287 | if (function == "api") | 287 | if (function == "api") |
288 | m_log.Info(GenerateRuntimeAPI()); | 288 | m_log.Info(GenerateRuntimeAPI()); |
289 | ShowConsoleHelp(); | 289 | ShowConsoleHelp(); |
290 | } | 290 | } |
291 | } | 291 | } |
292 | 292 | ||
293 | #endregion | 293 | #endregion |
294 | 294 | ||
295 | private void ShowConsoleHelp() | 295 | private void ShowConsoleHelp() |
296 | { | 296 | { |
297 | m_log.Info("===" + m_name + "==="); | 297 | m_log.Info("===" + m_name + "==="); |
298 | foreach (ICommand com in m_commands.Values) | 298 | foreach (ICommand com in m_commands.Values) |
299 | { | 299 | { |
300 | m_log.Info("* " + com.Name + " - " + com.Help); | 300 | m_log.Info("* " + com.Name + " - " + com.Help); |
301 | } | 301 | } |
302 | } | 302 | } |
303 | 303 | ||
304 | private string EscapeRuntimeAPICommand(string command) | 304 | private string EscapeRuntimeAPICommand(string command) |
305 | { | 305 | { |
306 | command = command.Replace('-', '_'); | 306 | command = command.Replace('-', '_'); |
307 | StringBuilder tmp = new StringBuilder(command); | 307 | StringBuilder tmp = new StringBuilder(command); |
308 | tmp[0] = tmp[0].ToString().ToUpper().ToCharArray()[0]; | 308 | tmp[0] = tmp[0].ToString().ToUpper().ToCharArray()[0]; |
309 | 309 | ||
310 | return tmp.ToString(); | 310 | return tmp.ToString(); |
311 | } | 311 | } |
312 | } | 312 | } |
313 | } \ No newline at end of file | 313 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/CommanderTestModule.cs b/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/CommanderTestModule.cs index fffb19e..8d1371c 100644 --- a/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/CommanderTestModule.cs +++ b/OpenSim/Region/Environment/Modules/Framework/InterfaceCommander/CommanderTestModule.cs | |||
@@ -1,89 +1,89 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using Nini.Config; | 29 | using Nini.Config; |
30 | using OpenSim.Region.Environment.Interfaces; | 30 | using OpenSim.Region.Environment.Interfaces; |
31 | using OpenSim.Region.Environment.Modules.Framework.InterfaceCommander; | 31 | using OpenSim.Region.Environment.Modules.Framework.InterfaceCommander; |
32 | using OpenSim.Region.Environment.Scenes; | 32 | using OpenSim.Region.Environment.Scenes; |
33 | 33 | ||
34 | namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander | 34 | namespace OpenSim.Region.Environment.Modules.Framework.InterfaceCommander |
35 | { | 35 | { |
36 | public class CommanderTestModule : IRegionModule, ICommandableModule | 36 | public class CommanderTestModule : IRegionModule, ICommandableModule |
37 | { | 37 | { |
38 | private readonly Commander m_commander = new Commander("CommanderTest"); | 38 | private readonly Commander m_commander = new Commander("CommanderTest"); |
39 | private Scene m_scene; | 39 | private Scene m_scene; |
40 | 40 | ||
41 | #region ICommandableModule Members | 41 | #region ICommandableModule Members |
42 | 42 | ||
43 | public ICommander CommandInterface | 43 | public ICommander CommandInterface |
44 | { | 44 | { |
45 | get { throw new NotImplementedException(); } | 45 | get { throw new NotImplementedException(); } |
46 | } | 46 | } |
47 | 47 | ||
48 | #endregion | 48 | #endregion |
49 | 49 | ||
50 | #region IRegionModule Members | 50 | #region IRegionModule Members |
51 | 51 | ||
52 | public void Initialise(Scene scene, IConfigSource source) | 52 | public void Initialise(Scene scene, IConfigSource source) |
53 | { | 53 | { |
54 | m_scene = scene; | 54 | m_scene = scene; |
55 | } | 55 | } |
56 | 56 | ||
57 | public void PostInitialise() | 57 | public void PostInitialise() |
58 | { | 58 | { |
59 | Command testCommand = new Command("hello", InterfaceHelloWorld, "Says a simple debugging test string"); | 59 | Command testCommand = new Command("hello", InterfaceHelloWorld, "Says a simple debugging test string"); |
60 | testCommand.AddArgument("world", "Write world here", "string"); | 60 | testCommand.AddArgument("world", "Write world here", "string"); |
61 | 61 | ||
62 | m_commander.RegisterCommand("hello", testCommand); | 62 | m_commander.RegisterCommand("hello", testCommand); |
63 | 63 | ||
64 | // Register me | 64 | // Register me |
65 | m_scene.RegisterModuleCommander("commandertest", m_commander); | 65 | m_scene.RegisterModuleCommander("commandertest", m_commander); |
66 | } | 66 | } |
67 | 67 | ||
68 | public void Close() | 68 | public void Close() |
69 | { | 69 | { |
70 | } | 70 | } |
71 | 71 | ||
72 | public string Name | 72 | public string Name |
73 | { | 73 | { |
74 | get { return "CommanderTestModule"; } | 74 | get { return "CommanderTestModule"; } |
75 | } | 75 | } |
76 | 76 | ||
77 | public bool IsSharedModule | 77 | public bool IsSharedModule |
78 | { | 78 | { |
79 | get { return false; } | 79 | get { return false; } |
80 | } | 80 | } |
81 | 81 | ||
82 | #endregion | 82 | #endregion |
83 | 83 | ||
84 | private void InterfaceHelloWorld(Object[] args) | 84 | private void InterfaceHelloWorld(Object[] args) |
85 | { | 85 | { |
86 | Console.WriteLine("Hello World"); | 86 | Console.WriteLine("Hello World"); |
87 | } | 87 | } |
88 | } | 88 | } |
89 | } \ No newline at end of file | 89 | } \ No newline at end of file |