private static Control BuildEditControl(IGeneratorAction action, Type control)
        {
            var editControl = ReflectionHelpers.CreateTypeInstance <InputFieldControl>(control);

            if (editControl == null)
            {
                throw new InvalidOperationException("Could not create instance of edit control");
            }

            var groupBox = new GroupBox()
            {
                Margin  = new Padding(0, 0, 5, 9),
                Padding = new Padding(5),
                Name    = string.Format("inputField_{0}", action.GetType().Name),
                Width   = editControl.Width + 10,
                Height  = editControl.Height + 25,
                Text    = action.ActionName
            };

            editControl.Dock   = DockStyle.Top;
            editControl.Action = action;

            groupBox.Controls.Add(editControl);

            return(groupBox);
        }
Пример #2
0
        private void Rollback(List <XmlGeneratorAction> actions, IGeneratorAction lastAction)
        {
            var rollbackList = new Dictionary <IGeneratorAction, XmlGeneratorAction>();

            actions.Reverse();

            foreach (var action in actions)
            {
                var actionClass = GetActionFromTypeName(action.ActionType);

                // If the actionname matched the last executed action (the one that failed),
                // or we already added a rollbackaction, we are allowed to add to the rollback list
                if (actionClass.ActionName == lastAction.ActionName || rollbackList.Count > 0)
                {
                    // From this point we add to our rollback list
                    rollbackList.Add(actionClass, action);
                }
            }

            foreach (var rollbackAction in rollbackList)
            {
                // Only rollback when the item supports it
                if (!rollbackAction.Key.SupportsRollback)
                {
                    continue;
                }

                var userAllowsRollback = false;

                // Ask the user if the rollback is allowed. Sometime not all actions have to be rolled back
                rollback(rollbackAction.Key.ActionName, rollbackAction.Key.RollBackMessage, out userAllowsRollback);

                if (userAllowsRollback)
                {
                    progress(-1, "Rolling back action: " + rollbackAction.Key.ActionName);

                    try
                    {
                        rollbackAction.Key.RollbackAction(arguments, arguments.InputValues, rollbackAction.Value.Parameters);
                    }
                    catch (Exception ex)
                    {
                        progress(-1, string.Format("Exception in rollback '{0}': {1}", rollbackAction.Key.ActionName, ex.Message));
                    }
                }
            }
        }
Пример #3
0
        private void Rollback(List<XmlGeneratorAction> actions, IGeneratorAction lastAction)
        {
            var rollbackList = new Dictionary<IGeneratorAction, XmlGeneratorAction>();

            actions.Reverse();

            foreach (var action in actions)
            {
                var actionClass = GetActionFromTypeName(action.ActionType);

                // If the actionname matched the last executed action (the one that failed),
                // or we already added a rollbackaction, we are allowed to add to the rollback list
                if (actionClass.ActionName == lastAction.ActionName || rollbackList.Count > 0)
                {
                    // From this point we add to our rollback list
                    rollbackList.Add(actionClass, action);
                }
            }

            foreach (var rollbackAction in rollbackList)
            {
                // Only rollback when the item supports it
                if (!rollbackAction.Key.SupportsRollback)
                    continue;

                var userAllowsRollback = false;

                // Ask the user if the rollback is allowed. Sometime not all actions have to be rolled back
                rollback(rollbackAction.Key.ActionName, rollbackAction.Key.RollBackMessage, out userAllowsRollback);

                if (userAllowsRollback)
                {
                    progress(-1, "Rolling back action: " + rollbackAction.Key.ActionName);

                    try
                    {
                        rollbackAction.Key.RollbackAction(arguments, arguments.InputValues, rollbackAction.Value.Parameters);
                    }
                    catch (Exception ex)
                    {
                        progress(-1, string.Format("Exception in rollback '{0}': {1}", rollbackAction.Key.ActionName, ex.Message));
                    }
                }
            }
        }
Пример #4
0
        private static Control BuildEditControl(IGeneratorAction action, Type control)
        {
            var editControl = ReflectionHelpers.CreateTypeInstance<InputFieldControl>(control);

            if (editControl == null)
                throw new InvalidOperationException("Could not create instance of edit control");

            var groupBox = new GroupBox()
            {
                Margin = new Padding(0, 0, 5, 9),
                Padding = new Padding(5),
                Name = string.Format("inputField_{0}", action.GetType().Name),
                Width = editControl.Width + 10,
                Height = editControl.Height + 25,
                Text = action.ActionName
            };

            editControl.Dock = DockStyle.Top;
            editControl.Action = action;

            groupBox.Controls.Add(editControl);

            return groupBox;
        }