コード例 #1
0
        private void collectRemoveCommands(TStartValueDTO elementToRemove, BulkUpdateMacroCommand collector)
        {
            var startValue = StartValueFrom(elementToRemove);

            if (_buildingBlock.Contains(startValue))
            {
                collector.AddCommand(_startValuesTask.RemoveStartValueFromBuildingBlockCommand(startValue, _buildingBlock));
            }
        }
コード例 #2
0
        private MoBiMacroCommand createExtendMacroCommand(TBuildingBlock buildingBlockToExtend)
        {
            var moBiMacroCommand = new BulkUpdateMacroCommand
            {
                CommandType = AppConstants.Commands.ExtendCommand,
                Description = AppConstants.Commands.ExtendDescription,
                ObjectType  = _interactionTaskContext.GetTypeFor(buildingBlockToExtend)
            };

            return(moBiMacroCommand);
        }
        protected MoBiMacroCommand CreateMergeMacroCommand(TBuildingBlock targetBuildingBlock)
        {
            var moBiMacroCommand = new BulkUpdateMacroCommand
            {
                CommandType = AppConstants.Commands.MergeCommand,
                Description = AppConstants.Commands.MergeBuildingBlocks,
                ObjectType  = _interactionTaskContext.GetTypeFor(targetBuildingBlock)
            };

            return(moBiMacroCommand);
        }
コード例 #4
0
        public override IMoBiCommand ImportStartValuesToBuildingBlock(IMoleculeStartValuesBuildingBlock startValuesBuildingBlock, IEnumerable <ImportedQuantityDTO> startValues)
        {
            var macroCommand = new BulkUpdateMacroCommand
            {
                CommandType = AppConstants.Commands.ImportCommand,
                Description = AppConstants.Commands.ImportMoleculeStartValues,
                ObjectType  = ObjectTypes.MoleculeStartValue
            };

            GetImportStartValuesMacroCommand(startValuesBuildingBlock, startValues, macroCommand);

            return(macroCommand.Run(Context));
        }
コード例 #5
0
        public override void TransferImportedQuantities()
        {
            var macroCommand = new BulkUpdateMacroCommand
            {
                Description = AppConstants.Commands.ImportMultipleParameters,
                CommandType = AppConstants.Commands.EditCommand,
                ObjectType  = ObjectTypes.Parameter
            };

            _quantityDTOs.Each(dto => macroCommand.Add(_quantityTask.SetQuantityBaseValue(dto.Path.TryResolve <IParameter>(_simulation.Model.Root), dto.QuantityInBaseUnit, _simulation)));

            AddCommand(macroCommand);
        }
コード例 #6
0
        private void bulkRemove(IReadOnlyList <TStartValueDTO> startValuesToRemove)
        {
            var macroCommand = new BulkUpdateMacroCommand();

            startValuesToRemove.Each(value => collectRemoveCommands(value, macroCommand));

            macroCommand.CommandType = AppConstants.Commands.DeleteCommand;
            macroCommand.ObjectType  = new ObjectTypeResolver().TypeFor <TStartValue>();
            macroCommand.Description = AppConstants.Commands.RemoveMultipleStartValues;

            AddCommand(macroCommand.Run(_context));

            _startValueDTOs.RemoveRange(startValuesToRemove);
        }
コード例 #7
0
        protected void GetImportStartValuesMacroCommand(TBuildingBlock startValuesBuildingBlock, IEnumerable <ImportedQuantityDTO> startValues, BulkUpdateMacroCommand macroCommand)
        {
            startValues.Each(startValueDTO =>
            {
                var startValue = startValuesBuildingBlock[startValueDTO.Path];

                if (startValue == null)
                {
                    macroCommand.Add(GenerateAddCommand(startValuesBuildingBlock, _dtoToQuantityToParameterStartValueMapper.MapFrom(startValueDTO)));
                }
                else
                {
                    if (ShouldFormulaBeOverridden(startValueDTO, startValue))
                    {
                        macroCommand.Add(GetChangeStartValueFormulaCommand(startValuesBuildingBlock, startValue: startValue, newFormula: null, oldFormula: startValue.Formula));
                    }

                    macroCommand.Add(GetUpdateStartValueInBuildingBlockCommand(startValuesBuildingBlock, startValueDTO));
                }
            });
        }