/
CommandManager.cs
36 lines (30 loc) · 1.1 KB
/
CommandManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
namespace PhoneGap {
class CommandManager {
private Command[] commands = new Command[ 10 ];
public CommandManager() {
commands[ 0 ] = new AccelerometerCommand();
commands[ 1 ] = new CameraCommand();
commands[ 2 ] = new ContactCommand();
commands[ 3 ] = new DeviceCommand();
commands[ 4 ] = new FileCommand();
commands[ 5 ] = new GeolocationCommand();
commands[ 6 ] = new MediaCommand();
commands[ 7 ] = new NotificationCommand();
commands[ 8 ] = new SMSCommand();
commands[ 9 ] = new TelephonyCommand();
}
public String processInstruction(String instruction) {
for (int index = 0; index < commands.Length; index++) {
Command command = (Command) commands[index];
if (command.accept(instruction))
try {
return command.execute(instruction);
} catch(Exception e) {
System.Diagnostics.Debug.WriteLine( e, "bug" );
}
}
return null;
}
}
}