Exemplo n.º 1
0
        public TObjectBase CreateCloneFor(TObjectBase objectToClone)
        {
            var entityType = _objectTypeResolver.TypeFor(objectToClone);

            _view.Caption         = Captions.ParameterIdentification.Clone;
            _view.NameDescription = Captions.CloneObjectBase(entityType, objectToClone.Name);
            _view.Icon            = ApplicationIcons.Clone;
            _renameObjectBaseDTO  = _renameObjectBaseDTOFactory.CreateFor(objectToClone);
            _renameObjectBaseDTO.AllowSameNameAsOriginalInDifferentCase = false;
            _renameObjectBaseDTO.Description = objectToClone.Description;
            _view.BindTo(_renameObjectBaseDTO);
            _view.Display();

            if (_view.Canceled)
            {
                return(null);
            }

            var clonedObject = Clone(objectToClone);

            clonedObject.Name        = _renameObjectBaseDTO.Name;
            clonedObject.Description = _renameObjectBaseDTO.Description;

            return(clonedObject);
        }
Exemplo n.º 2
0
        public IPKSimBuildingBlock CreateCloneFor(IPKSimBuildingBlock buildingBlockToClone)
        {
            //This should never fail
            var expressionProfile = buildingBlockToClone.DowncastTo <ExpressionProfile>();

            var(molecule, _) = expressionProfile;
            _dto             = _expressionProfileDTOMapper.MapFrom(expressionProfile);
            _view.Caption    = Captions.CloneObjectBase(PKSimConstants.ObjectTypes.ExpressionProfile, buildingBlockToClone.Name);

            _view.BindTo(_dto);
            _view.Display();

            if (_view.Canceled)
            {
                return(null);
            }

            //create a new expression profile using the same molecule name as the original so that we can update the values. Then we rename
            var newExpressionProfile = _expressionProfileFactory.Create(molecule.MoleculeType, _dto.Species.Name, molecule.Name);

            newExpressionProfile.Category = _dto.Category;

            //synchronize values
            _expressionProfileUpdater.SynchronizeExpressionProfileWithExpressionProfile(expressionProfile, newExpressionProfile);

            //rename using the new name
            _expressionProfileUpdater.UpdateMoleculeName(newExpressionProfile, _dto.MoleculeName);

            return(newExpressionProfile);
        }
 public void should_set_the_description_for_the_view_according_to_the_entity_type_and_name()
 {
     _view.NameDescription.ShouldBeEqualTo(Captions.CloneObjectBase(_entityType, _entityName));
 }