コード例 #1
0
        private void DoExecute()
        {
            CommandDescriptor commandDescriptor =
                PublicCommandsHelper.GetCommandDescriptor(ControllerCommandType);

            commandDescriptor.ClearParameterValues();
            OperationParametersControlCreator.ReadParameterValues(commandDescriptor, controls);
            foreach (ParameterDescriptor parameterDescriptor in commandDescriptor.Parameters)
            {
                if (parameterDescriptor.ParameterPropertyInfo == commandDescriptor.ScopeProperty)
                {
                    parameterDescriptor.ParameterValue = ((ExolutioObject)this.ScopeObject).ID;
                }
            }
            CreateControllerCommand();
            CommandSerializer.FillParameters(ControllerCommand, commandDescriptor);
            ControllerCommand.CanExecuteChanged -= OnControllerCommandCanExecuteChanged;
            if (!ControllerCommand.CanExecute())
            {
#if SILVERLIGHT
                ExolutioErrorMsgBox.Show("Command can not be executed", ControllerCommand.ErrorDescription);
#else
                ExolutioErrorMsgBox.Show("Command can not be executed", ControllerCommand.ErrorDescription);
#endif
            }
            else
            {
                if (ControllerCommand is StackedCommand)
                {
                    if (((StackedCommand)ControllerCommand).Controller == null)
                    {
                        ((StackedCommand)ControllerCommand).Controller = Current.Controller;
                    }
                }
                try
                {
                    ControllerCommand.Execute();
                }
                catch (ExolutioCommandException e)
                {
                    ExolutioErrorMsgBox.Show("Command " + e.Command.GetType().ToString() + " can not be executed", e.Command.ErrorDescription);
                }
            }
            ControllerCommand = null;
        }