コード例 #1
0
ファイル: CliHandler.cs プロジェクト: DopeDb/cs-backend
        public void InvokeCliCall(CliCall cliCall)
        {
            var commandName = $"{cliCall.ControllerName}:{cliCall.ActionName}";
            var command     = GetCommand(commandName);

            if (command == null)
            {
                Util.WriteLine($"<error>Command {commandName} is unknown</error>");
                Util.WriteLine("Call help:list to see all available commands");
                return;
            }
            var commandController = ObjectManager.Instance().Get(command.DeclaringType);
            var arguments         = MapArguments(command, cliCall);
            var request           = new CliRequest();

            request.ActionName     = cliCall.ActionName;
            request.ControllerName = cliCall.ControllerName;
            request.Arguments      = new Dictionary <string, object>();
            foreach (var parameter in command.GetParameters())
            {
                request.Arguments.Add(parameter.Name, arguments[parameter.Position]);
            }
            ((AbstractCliController)commandController).SetCliReqest(request);
            var actionName = Text.FirstCharToUpper(cliCall.ActionName) + "Command";

            command.Invoke(commandController, arguments);
        }
コード例 #2
0
 public void SetCliReqest(CliRequest request)
 {
     this.request = request;
 }