예제 #1
0
        private ICommand synchronizedCommand(IQuantity quantity, IMoBiSimulation simulation, IMoBiCommand simulationCommandToBeRun, bool shouldUpdateValueOriginAndState = true)
        {
            var macroCommand = new MoBiMacroCommand();

            //add one before setting the value in the simulation to enable correct undo
            macroCommand.Add(_quantitySynchronizer.Synchronize(quantity, simulation));

            IOSPSuiteCommand executedCommand = simulationCommandToBeRun.AsHidden().Run(_context);

            if (shouldUpdateValueOriginAndState)
            {
                executedCommand = withUpdatedDefaultStateAndValueOrigin(executedCommand, quantity, simulation);
            }

            macroCommand.Add(executedCommand);

            macroCommand.Add(_quantitySynchronizer.Synchronize(quantity, simulation));

            //needs to be done at the end because description might be set only after run
            return(macroCommand.WithHistoryEntriesFrom(simulationCommandToBeRun));
        }