Ejemplo n.º 1
0
 public string NewNameFor(IWithName withName, IEnumerable <string> forbiddenNames = null, string entityType = null)
 {
     using (var renamePresenter = getRenameObjectPresenterFor(withName))
     {
         return(renamePresenter.NewNameFrom(withName, forbiddenNames, entityType));
     }
 }
Ejemplo n.º 2
0
 public string NewNameFor(IWithName withName, IEnumerable <string> forbiddenNames = null, string entityType = null)
 {
     using (var renamePresenter = _applicationController.Start <IRenameObjectPresenter>())
     {
         return(renamePresenter.NewNameFrom(withName, forbiddenNames, entityType));
     }
 }
Ejemplo n.º 3
0
        public RenameObjectDTO CreateFor(IWithName objectBase)
        {
            //Entity might be a building block in disguise!
            var buildingBlock = objectBase as IPKSimBuildingBlock;

            if (buildingBlock != null)
            {
                return(createFor(buildingBlock));
            }

            var parameterAnalyzable = objectBase as IParameterAnalysable;

            if (parameterAnalyzable != null)
            {
                return(createFor(parameterAnalyzable));
            }

            var dto = new RenameObjectDTO(objectBase.Name);

            var entity = objectBase as IEntity;

            if (entity?.ParentContainer == null)
            {
                return(dto);
            }

            dto.ContainerType = _objectTypeResolver.TypeFor(entity.ParentContainer);
            dto.AddUsedNames(entity.ParentContainer.AllChildrenNames());

            return(dto);
        }
Ejemplo n.º 4
0
 public static bool IsNamed(this IWithName withName, string name)
 {
     if (withName == null)
     {
         return(false);
     }
     return(string.Equals(withName.Name, name));
 }
Ejemplo n.º 5
0
        public override RenameObjectDTO CreateFor(IWithName objectBase)
        {
            if (objectBase is IPKSimBuildingBlock buildingBlock)
            {
                return(createFor(buildingBlock));
            }

            return(base.CreateFor(objectBase));
        }
Ejemplo n.º 6
0
        private RenameObjectDTO createRenameInProjectDTO(IWithName withName, IEnumerable <IWithName> existingObjects)
        {
            var dto = new RenameObjectDTO(withName.Name)
            {
                ContainerType = PKSimConstants.ObjectTypes.Project
            };

            dto.AddUsedNames(existingObjects.AllNames());
            return(dto);
        }
Ejemplo n.º 7
0
        protected RenameObjectDTO CreateRenameInContainerDTO(IWithName withName, IEnumerable <IWithName> existingObjects, string containerType)
        {
            var dto = new RenameObjectDTO(withName.Name)
            {
                ContainerType = containerType
            };

            dto.AddUsedNames(existingObjects.AllNames());
            return(dto);
        }
Ejemplo n.º 8
0
        public async Task ExportSnapshot(IWithName snapshotObject)
        {
            var fileName = fileNameForExport(snapshotObject);

            if (string.IsNullOrEmpty(fileName))
            {
                return;
            }

            await saveSnapshotToFile(snapshotObject, fileName);
        }
Ejemplo n.º 9
0
        private IRenamePresenter getRenameObjectPresenterFor(IWithName entityToRename)
        {
            switch (entityToRename)
            {
            case ExpressionProfile _:
                return(_applicationController.Start <IRenameExpressionProfilePresenter>());

            default:
                return(_applicationController.Start <IRenameObjectPresenter>());
            }
        }
Ejemplo n.º 10
0
        protected override void Context()
        {
            _entityTask     = A.Fake <IEntityTask>();
            _eventPublisher = A.Fake <IEventPublisher>();
            _anObject       = A.Fake <IWithName>();

            sut = new RenameObjectUICommand(_entityTask, _eventPublisher)
            {
                Subject = _anObject
            };
        }
 protected override void Context()
 {
     _view                   = A.Fake <IObjectBaseView>();
     _objectToRename         = A.Fake <IWithName>();
     _renameObjectDTOFactory = A.Fake <IRenameObjectDTOFactory>();
     _entityType             = "type";
     _entityName             = "tutu";
     _objectToRename.Name    = _entityName;
     _renameObjectDTO        = new RenameObjectDTO(_entityName);
     _objectTypeResolver     = A.Fake <IObjectTypeResolver>();
     A.CallTo(() => _objectTypeResolver.TypeFor(_objectToRename)).Returns(_entityType);
     A.CallTo(() => _renameObjectDTOFactory.CreateFor(_objectToRename)).Returns(_renameObjectDTO);
     sut = new RenameObjectPresenter(_view, _objectTypeResolver, _renameObjectDTOFactory);
 }
Ejemplo n.º 12
0
        ///   <summary>
        ///      Get Key For Value from dictionary
        ///      <example>
        ///        <code>
        ///         var columnId = Board.GetKeyForValue("Resolve", Columns).columnId
        ///        </code>
        ///      </example>
        ///    </summary>
        public static T GetKeyForValue <T>(string value, Dictionary <long, T> dictionary)
        {
            long key = dictionary.Keys.First();

            foreach (KeyValuePair <long, T> s in dictionary)
            {
                IWithName item = (IWithName)s.Value;
                if (value == item.Name)
                {
                    key = s.Key;
                }
            }

            return((T)dictionary[key]);
        }
Ejemplo n.º 13
0
        public RenameObjectDTO CreateFor(IWithName objectBase)
        {
            var dto = new RenameObjectDTO(objectBase.Name);

            var entity = objectBase as IEntity;

            if (entity == null || entity.ParentContainer == null)
            {
                return(dto);
            }

            dto.ContainerType = _objectTypeResolver.TypeFor(entity.ParentContainer);
            dto.AddUsedNames(entity.ParentContainer.AllChildrenNames());

            return(dto);
        }
Ejemplo n.º 14
0
        public virtual RenameObjectDTO CreateFor(IWithName objectBase)
        {
            if (objectBase is IParameterAnalysable parameterAnalyzable)
            {
                return(CreateFor(parameterAnalyzable));
            }

            var entity = objectBase as IEntity;

            if (entity?.ParentContainer == null)
            {
                return(new RenameObjectDTO(objectBase.Name));
            }

            var containerType = _objectTypeResolver.TypeFor(entity.ParentContainer);

            return(CreateRenameInContainerDTO(entity, entity.ParentContainer.Children, containerType));
        }
Ejemplo n.º 15
0
        public string NewNameFrom(IWithName namedObject, IEnumerable <string> forbiddenNames, string entityType = null)
        {
            //This should never fail
            var expressionProfile = namedObject.DowncastTo <ExpressionProfile>();

            _expressionProfileDTO = _expressionProfileDTOMapper.MapFrom(expressionProfile);
            _view.Caption         = PKSimConstants.UI.RenameEntityCaption(PKSimConstants.ObjectTypes.ExpressionProfile, namedObject.Name);

            _view.BindTo(_expressionProfileDTO);
            _view.Display();

            if (_view.Canceled)
            {
                return(string.Empty);
            }

            return(_expressionProfileDTO.Name);
        }
Ejemplo n.º 16
0
 public static bool NameIsOneOf(this IWithName withName, params string[] names)
 {
     return(withName.NameIsOneOf(names.ToList()));
 }
Ejemplo n.º 17
0
 public static bool NameIsOneOf(this IWithName withName, IEnumerable <string> names)
 {
     return(names.Any(withName.IsNamed));
 }
Ejemplo n.º 18
0
 public RenamedEvent(IWithName renameObject)
 {
     RenamedObject = renameObject;
 }
Ejemplo n.º 19
0
 protected override void Context()
 {
     base.Context();
     _objectToClone = A.Fake <IWithName>().WithName("TOTO");
 }
Ejemplo n.º 20
0
 protected override void Context()
 {
     base.Context();
     _withName = A.Fake <IWithName>();
     A.CallTo(() => _mdiChildPresenter.Subject).Returns(_withName);
 }
Ejemplo n.º 21
0
        private string fileNameForExport(IWithName objectToExport)
        {
            var message = PKSimConstants.UI.SelectSnapshotExportFile(objectToExport.Name, _objectTypeResolver.TypeFor(objectToExport));

            return(_dialogCreator.AskForFileToSave(message, Constants.Filter.JSON_FILE_FILTER, Constants.DirectoryKey.REPORT, objectToExport.Name));
        }
Ejemplo n.º 22
0
 private string createFilePathFor(IWithName objectWithName, string exportDirectory, string extension, bool replaceSpaces = false)
 {
     return(Path.Combine(exportDirectory, createFileNameFor(objectWithName, extension, replaceSpaces)));
 }
Ejemplo n.º 23
0
 protected RenameObjectDTO CreateRenameInProjectDTO(IWithName withName, IEnumerable <IWithName> existingObjects) => CreateRenameInContainerDTO(withName, existingObjects, ObjectTypes.Project);
Ejemplo n.º 24
0
        private static string createFileNameFor(IWithName objectWithName, string extension, bool replaceSpaces = false)
        {
            var baseFileName = $"{objectWithName.Name}{extension}";

            return(!replaceSpaces ? baseFileName : baseFileName.Replace(" ", "_"));
        }