public RemoveUseCaseEditorParameterCommand(UseCaseEditorControlViewModel vm, ParameterDirection direction) { Initialize((input) => { try { var useCaseItem = direction == ParameterDirection.Input ? vm.SelectedInputUseCaseParameter : vm.SelectedOutputUseCaseParameter; if (direction == ParameterDirection.Input) { var parameters = vm.UseCase.InputParameters; parameters.Remove((DataParameterModel)input); vm.UseCase.InputParameters = parameters; } else if (direction == ParameterDirection.Output) { var parameters = vm.UseCase.OutputParameters; parameters.Remove((DataParameterModel)input); vm.UseCase.OutputParameters = parameters; } vm.RaiseCanExecuteCommandChanged(); } catch (Exception ex) { vm.RaiseError(ex.Message); } }, data => { return(direction == ParameterDirection.Input && vm.SelectedInputUseCaseParameter != null || direction == ParameterDirection.Output && vm.SelectedOutputUseCaseParameter != null); }); }
public AddUseCaseEditorParameterCommand(UseCaseEditorControlViewModel vm, ParameterDirection direction) { Initialize((input) => { try { var requestModel = new GenericFormModel("Add new parameter"); requestModel.AddAttribute(ActionParameterDefinition.TypeValue.String, Definitions.UseCaseEditorDefinitions.UseCaseModelAttibutes.Type, "Type", "Type of the parameter", DataParameter.GetUseCaseParameterTypesList().ToArray()); requestModel.AddAttribute( ActionParameterDefinition.TypeValue.String, Definitions.UseCaseEditorDefinitions.UseCaseModelAttibutes.Name, "Name", "Name of the parameter"); requestModel.AddAttribute(ActionParameterDefinition.TypeValue.String, Definitions.UseCaseEditorDefinitions.UseCaseModelAttibutes.EnumerableType, "Enumerable type", "If type=Enumerable, this is the type of the enumerable", DataParameter.GetUseCaseParameterTypesList().ToArray()); requestModel.AddAttribute( ActionParameterDefinition.TypeValue.String, Definitions.UseCaseEditorDefinitions.UseCaseModelAttibutes.DictionaryKeyType, "Dictionary key type", "If type=Dictionary, this is the type of the key", DataParameter.GetUseCaseParameterTypesList().ToArray()); requestModel.AddAttribute(ActionParameterDefinition.TypeValue.String, Definitions.UseCaseEditorDefinitions.UseCaseModelAttibutes.DictionaryValueType, "Dictionary value type", "If type=Dictionary, this is the type of the value", DataParameter.GetUseCaseParameterTypesList().ToArray()); vm.GenericFormRequestId = Guid.NewGuid(); if (direction == ParameterDirection.Input) { vm.CurrentFormInputActionType = UseCaseEditorControlViewModel.ActionType.AddInputParameter; } else if (direction == ParameterDirection.Output) { vm.CurrentFormInputActionType = UseCaseEditorControlViewModel.ActionType.AddOutputParameter; } vm.EventManager.RaiseOnGenericFormInputRequestedEvent(vm.GenericFormRequestId, requestModel); vm.RaiseCanExecuteCommandChanged(); } catch (Exception ex) { vm.RaiseError(ex.Message); } }, data => { return(direction == ParameterDirection.Input || (direction == ParameterDirection.Output && vm.UseCase?.OutputParameters.Count == 0)); }); }
public MoveUpDownUseCaseEditorParameterCommand(UseCaseEditorControlViewModel vm, ParameterDirection parameterDirection, MovementDirection movementDirection) { Initialize((input) => { try { var useCaseItem = vm.SelectedInputUseCaseParameter; var list = vm.UseCase.InputParameters; var item = vm.SelectedInputUseCaseParameter; var originalIndex = list.IndexOf(item); list.RemoveAt(originalIndex); if (movementDirection == MovementDirection.Up) { list.Insert(originalIndex - 1, item); } else if (movementDirection == MovementDirection.Down) { list.Insert(originalIndex + 1, item); } vm.UseCase.InputParameters = list; vm.SelectedInputUseCaseParameter = vm.UseCase.InputParameters.First(k => k.Name == item.Name); } catch (Exception ex) { vm.RaiseError(ex.Message); } }, data => { return(parameterDirection == ParameterDirection.Input && vm.SelectedInputUseCaseParameter != null && vm.UseCase?.InputParameters.Count > 0 && (movementDirection == MovementDirection.Down && vm.UseCase?.InputParameters.IndexOf(vm.SelectedInputUseCaseParameter) < vm.UseCase?.InputParameters.Count - 1) || (movementDirection == MovementDirection.Up && vm.UseCase?.InputParameters.IndexOf(vm.SelectedInputUseCaseParameter) > 0)); }); }