Exemple #1
0
        public override void Execute(Object parameter, INextCommandDelegate commandFinishedCallback)
        {
            if (RevertChangesSavepoint == null)
            {
                base.Execute(parameter, commandFinishedCallback);
                return;
            }
            if (parameter == null)
            {
                if (commandFinishedCallback != null)
                {
                    commandFinishedCallback.Invoke(true);
                }
                return;
            }
            IList <Object> businessObjects = ExtractBusinessObjects(parameter);

            RevertChangesFinishedCallback revertChangesFinishedCallback = null;

            if (commandFinishedCallback != null)
            {
                revertChangesFinishedCallback = new RevertChangesFinishedCallback(delegate(bool success)
                {
                    commandFinishedCallback.Invoke(success);
                });
            }

            IdentityHashSet <Object> mentionedBusinessObjects = new IdentityHashSet <Object>(businessObjects);
            IdentityHashSet <Object> savepointBusinessObjects = new IdentityHashSet <Object>(RevertChangesSavepoint.GetSavedBusinessObjects());

            mentionedBusinessObjects.RemoveAll(savepointBusinessObjects);

            RevertChangesSavepoint.RevertChanges();
            RevertChangesHelper.RevertChanges(mentionedBusinessObjects, revertChangesFinishedCallback);
        }