2 using com.andoutomo.kybernetes.view;
\r
3 using com.andoutomo.kybernetes.data.accessor;
\r
4 using com.andoutomo.kybernetes.data.DAO;
\r
5 using com.andoutomo.kybernetes.command;
\r
7 namespace com.andoutomo.kybernetes.control
\r
9 public class CmdDispatcher
\r
11 #region Singleton Setting
\r
12 private static CmdDispatcher singleton;
\r
13 private CmdDispatcher()
\r
16 internal static CmdDispatcher getDispatcher(BaseForm form)
\r
18 if (singleton == null)
\r
20 singleton = new CmdDispatcher(form);
\r
25 private BaseForm baseForm;
\r
27 private CmdDispatcher(BaseForm form)
\r
29 this.baseForm = form;
\r
33 /// コマンドをデータベースと照合して、処理の呼び出しを実施します。
\r
35 /// <param name="command"></param>
\r
36 /// <returns></returns>
\r
37 internal string dispatch(string command)
\r
39 //空文字の場合は改行を入れる(Unixの仕様に準拠)
\r
40 if (string.IsNullOrEmpty(command))
\r
42 return string.Empty;
\r
45 string retStr = string.Empty;
\r
46 string commandTop = command.Split(' ')[0];
\r
47 CommandData data = CommandDataAccessor.getObject.getCommandData(commandTop);
\r
53 Type argsType = Type.GetType(data.ArgClass);
\r
54 CommandArg args = (CommandArg)Activator.CreateInstance(argsType);
\r
56 args.split(command);
\r
58 Type commandType = Type.GetType(data.TargetClass);
\r
59 AbCommand commandCls = (AbCommand)Activator.CreateInstance(commandType);
\r
61 commandCls.run(args,baseForm);
\r
63 retStr = commandCls.getMessage();
\r
67 retStr = "エラーが発生しました。";
\r
68 new KybernetesApplicationException(e);
\r
73 retStr = "不明なコマンドです。";
\r