public AbstractBasicCondition DeepCopyCondition() { BasicCondition copy = new BasicCondition(); foreach (AbstractStatement statement in Statements) { copy.AddStatement(statement.DeepCopyStatement()); } return copy; }
public void AbstractConditionGroup_RemoveStatement() { var entity = new Entity(); var evt = new Event(Workspace.Instance.GetPlugin(typeof(TriggerOccursEvent))); var group = new ConditionGroup(); var elif = new ExpressionCondition(); var el = new BasicCondition(); group.AddStatement(elif); group.Else = el; evt.AddStatement(group); CommandHelper.TestUndoableCommand( () => Assert.AreEqual(elif, group.Statements.First()), () => entity.DeleteStatementCommand.Execute(elif), () => Assert.AreEqual(0, group.Statements.Count) ); CommandHelper.TestUndoableCommand( () => Assert.AreEqual(el, group.Else), () => entity.DeleteStatementCommand.Execute(el), () => Assert.IsNull(group.Else) ); }
protected AbstractConditionGroup(AbstractConditionGroup sourceGroup = null) : base(sourceGroup) { this.sourceGroup = sourceGroup; AddElseIfCommand = new DelegateCommand((parameter) => IsEditable, (parameter) => { if (IsEditable) { var condition = new ExpressionCondition(); AddStatement(condition); Workspace.Instance.CommandHistory.Log( "add else if", () => AddStatement(condition), () => RemoveStatement(condition) ); } }); AddElseCommand = new DelegateCommand((parameter) => IsEditable && null == Else, (parameter) => { if (IsEditable && null == Else) { var condition = new BasicCondition(); Else = condition; Workspace.Instance.CommandHistory.Log( "add else", () => Else = condition, () => Else = null ); } }); }