public string NewNameFor(IWithName withName, IEnumerable <string> forbiddenNames = null, string entityType = null) { using (var renamePresenter = getRenameObjectPresenterFor(withName)) { return(renamePresenter.NewNameFrom(withName, forbiddenNames, entityType)); } }
public string NewNameFor(IWithName withName, IEnumerable <string> forbiddenNames = null, string entityType = null) { using (var renamePresenter = _applicationController.Start <IRenameObjectPresenter>()) { return(renamePresenter.NewNameFrom(withName, forbiddenNames, entityType)); } }
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); }
public static bool IsNamed(this IWithName withName, string name) { if (withName == null) { return(false); } return(string.Equals(withName.Name, name)); }
public override RenameObjectDTO CreateFor(IWithName objectBase) { if (objectBase is IPKSimBuildingBlock buildingBlock) { return(createFor(buildingBlock)); } return(base.CreateFor(objectBase)); }
private RenameObjectDTO createRenameInProjectDTO(IWithName withName, IEnumerable <IWithName> existingObjects) { var dto = new RenameObjectDTO(withName.Name) { ContainerType = PKSimConstants.ObjectTypes.Project }; dto.AddUsedNames(existingObjects.AllNames()); return(dto); }
protected RenameObjectDTO CreateRenameInContainerDTO(IWithName withName, IEnumerable <IWithName> existingObjects, string containerType) { var dto = new RenameObjectDTO(withName.Name) { ContainerType = containerType }; dto.AddUsedNames(existingObjects.AllNames()); return(dto); }
public async Task ExportSnapshot(IWithName snapshotObject) { var fileName = fileNameForExport(snapshotObject); if (string.IsNullOrEmpty(fileName)) { return; } await saveSnapshotToFile(snapshotObject, fileName); }
private IRenamePresenter getRenameObjectPresenterFor(IWithName entityToRename) { switch (entityToRename) { case ExpressionProfile _: return(_applicationController.Start <IRenameExpressionProfilePresenter>()); default: return(_applicationController.Start <IRenameObjectPresenter>()); } }
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); }
/// <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]); }
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); }
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)); }
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); }
public static bool NameIsOneOf(this IWithName withName, params string[] names) { return(withName.NameIsOneOf(names.ToList())); }
public static bool NameIsOneOf(this IWithName withName, IEnumerable <string> names) { return(names.Any(withName.IsNamed)); }
public RenamedEvent(IWithName renameObject) { RenamedObject = renameObject; }
protected override void Context() { base.Context(); _objectToClone = A.Fake <IWithName>().WithName("TOTO"); }
protected override void Context() { base.Context(); _withName = A.Fake <IWithName>(); A.CallTo(() => _mdiChildPresenter.Subject).Returns(_withName); }
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)); }
private string createFilePathFor(IWithName objectWithName, string exportDirectory, string extension, bool replaceSpaces = false) { return(Path.Combine(exportDirectory, createFileNameFor(objectWithName, extension, replaceSpaces))); }
protected RenameObjectDTO CreateRenameInProjectDTO(IWithName withName, IEnumerable <IWithName> existingObjects) => CreateRenameInContainerDTO(withName, existingObjects, ObjectTypes.Project);
private static string createFileNameFor(IWithName objectWithName, string extension, bool replaceSpaces = false) { var baseFileName = $"{objectWithName.Name}{extension}"; return(!replaceSpaces ? baseFileName : baseFileName.Replace(" ", "_")); }