public async Task <IResponse <ITasksGroup> > SaveAsync(string groupName) { try { ITasksGroup tasksGroup = mTaskGroupFactory.CreateGroup(groupName); if (!mTasksGroupNameValidator.IsNameValid(tasksGroup.Name)) { return(new FailResponse <ITasksGroup>( $"Group name '{tasksGroup.Name}' exceeds the maximal group name length: {NameLengths.MaximalGroupNameLength}")); } if (!await mTasksGroupRepository.AddAsync(tasksGroup).ConfigureAwait(false)) { return(new FailResponse <ITasksGroup>( $"Group name '{tasksGroup.Name}' already exist")); } return(new SuccessResponse <ITasksGroup>(tasksGroup)); } catch (Exception ex) { return(new FailResponse <ITasksGroup>($"An error occurred when saving tasks group name {groupName}: {ex.Message}")); } }
public async Task <IResponse <IWorkTask> > SaveTaskAsync(string taskGroupIdentifier, string workTaskDescription) { try { ITasksGroup tasksGroup = (await FindTasksGroupsByConditionAsync(group => group.ID == taskGroupIdentifier) .ConfigureAwait(false)) .FirstOrDefault(); if (tasksGroup == null && taskGroupIdentifier != null) { tasksGroup = (await FindTasksGroupsByConditionAsync(group => string.Equals(group.Name, taskGroupIdentifier, StringComparison.OrdinalIgnoreCase)) .ConfigureAwait(false)) .FirstOrDefault(); } if (tasksGroup == null) { return(new FailResponse <IWorkTask>($"Tasks group {taskGroupIdentifier} does not exist")); } if (!ValidateUniqueTaskDescription(tasksGroup, workTaskDescription)) { return(new FailResponse <IWorkTask>($"Tasks group {tasksGroup.Name} " + $"has already work task with description {workTaskDescription}")); } IWorkTask workTask = mTaskGroupFactory.CreateTask(tasksGroup, workTaskDescription); if (!mWorkTaskNameValidator.IsNameValid(workTask.Description)) { return(new FailResponse <IWorkTask>($"Task description'{workTask.Description}' is invalid")); } await mTasksGroupRepository.UpdateAsync(tasksGroup).ConfigureAwait(false); return(new SuccessResponse <IWorkTask>(workTask)); } catch (Exception ex) { return(new FailResponse <IWorkTask>($"An error occurred when saving work task {taskGroupIdentifier}: {ex.Message}")); } }
void Update() { //Update strength and speed values if they have changed. Don't need to update twice since the sliders update each other. if (sliders.GetSpeed() != move.GetSpeed() || sliders.GetStrength() != move.GetStrength()) { updateStrengthAndSpeed(sliders.GetSpeed(), sliders.GetStrength()); UpdateShieldScale(); } //Update active bodypart. if (activeBodypartSelector.GetActiveBodypart() != null) { if (!activeBodypartSelector.GetActiveBodypart().Equals(move.GetActiveBodypart())) { move.SetActiveBodypart(activeBodypartSelector.GetActiveBodypart()); UpdateShieldScale(); } } if (recorder != null) { if (!doneRecordingFrames && recorder.IsDoneRecording()) { doneRecordingFrames = true; foreach (GameObject dragPoint in UnityUtils.RecursiveContains(character.transform, "DragPoint")) { dragPoint.SetActive(false); } foreach (GameObject marker in twistLimitMarkers) { marker.SetActive(false); } editorGuiManager.NextState(); } //All frames recorded and a new, non-empty, move name has been entered. if (recorder.IsDoneRecording() && nameValidator.IsNameValid()) { move.SetName(nameValidator.GetName()); saveButton.interactable = true; } else { saveButton.interactable = false; //hide button again if name is no longer valid. } } }
private void BtnConnect_LeftClick(object sender, EventArgs e) { string errorMessage = NameValidator.IsNameValid(tbPlayerName.Text); if (!string.IsNullOrEmpty(errorMessage)) { XNAMessageBox.Show(WindowManager, "Invalid Player Name", errorMessage); return; } ProgramConstants.PLAYERNAME = tbPlayerName.Text; UserINISettings.Instance.SkipConnectDialog.Value = chkRememberMe.Checked; UserINISettings.Instance.PersistentMode.Value = chkPersistentMode.Checked; UserINISettings.Instance.AutomaticCnCNetLogin.Value = chkAutoConnect.Checked; UserINISettings.Instance.PlayerName.Value = ProgramConstants.PLAYERNAME; UserINISettings.Instance.SaveSettings(); Connect?.Invoke(this, EventArgs.Empty); }
private void Finish() { ProgramConstants.GAME_VERSION = ClientConfiguration.Instance.ModMode ? "N/A" : CUpdater.GameVersion; DiscordHandler discordHandler = null; if (!string.IsNullOrEmpty(ClientConfiguration.Instance.DiscordAppId)) { discordHandler = new DiscordHandler(WindowManager); } var gameCollection = new GameCollection(); gameCollection.Initialize(GraphicsDevice); var lanLobby = new LANLobby(WindowManager, gameCollection, mapLoader.GameModes, mapLoader, discordHandler); var cncnetUserData = new CnCNetUserData(WindowManager); var cncnetManager = new CnCNetManager(WindowManager, gameCollection); var tunnelHandler = new TunnelHandler(WindowManager, cncnetManager); var topBar = new TopBar(WindowManager, cncnetManager); var optionsWindow = new OptionsWindow(WindowManager, gameCollection, topBar); var pmWindow = new PrivateMessagingWindow(WindowManager, cncnetManager, gameCollection, cncnetUserData); privateMessagingPanel = new PrivateMessagingPanel(WindowManager); var cncnetGameLobby = new CnCNetGameLobby(WindowManager, "MultiplayerGameLobby", topBar, mapLoader.GameModes, cncnetManager, tunnelHandler, gameCollection, cncnetUserData, mapLoader, discordHandler); var cncnetGameLoadingLobby = new CnCNetGameLoadingLobby(WindowManager, topBar, cncnetManager, tunnelHandler, mapLoader.GameModes, gameCollection, discordHandler); var cncnetLobby = new CnCNetLobby(WindowManager, cncnetManager, cncnetGameLobby, cncnetGameLoadingLobby, topBar, pmWindow, tunnelHandler, gameCollection, cncnetUserData); var gipw = new GameInProgressWindow(WindowManager); var skirmishLobby = new SkirmishLobby(WindowManager, topBar, mapLoader.GameModes, discordHandler); topBar.SetSecondarySwitch(cncnetLobby); var mainMenu = new MainMenu(WindowManager, skirmishLobby, lanLobby, topBar, optionsWindow, cncnetLobby, cncnetManager, discordHandler); WindowManager.AddAndInitializeControl(mainMenu); DarkeningPanel.AddAndInitializeWithControl(WindowManager, skirmishLobby); DarkeningPanel.AddAndInitializeWithControl(WindowManager, cncnetGameLoadingLobby); DarkeningPanel.AddAndInitializeWithControl(WindowManager, cncnetGameLobby); DarkeningPanel.AddAndInitializeWithControl(WindowManager, cncnetLobby); DarkeningPanel.AddAndInitializeWithControl(WindowManager, lanLobby); DarkeningPanel.AddAndInitializeWithControl(WindowManager, optionsWindow); WindowManager.AddAndInitializeControl(privateMessagingPanel); privateMessagingPanel.AddChild(pmWindow); topBar.SetTertiarySwitch(pmWindow); topBar.SetOptionsWindow(optionsWindow); WindowManager.AddAndInitializeControl(gipw); skirmishLobby.Disable(); cncnetLobby.Disable(); cncnetGameLobby.Disable(); cncnetGameLoadingLobby.Disable(); lanLobby.Disable(); pmWindow.Disable(); optionsWindow.Disable(); WindowManager.AddAndInitializeControl(topBar); topBar.AddPrimarySwitchable(mainMenu); mainMenu.PostInit(); if (UserINISettings.Instance.AutomaticCnCNetLogin && NameValidator.IsNameValid(ProgramConstants.PLAYERNAME) == null) { cncnetManager.Connect(); } WindowManager.RemoveControl(this); Cursor.Visible = visibleSpriteCursor; }
public void IsNameValid_NameIsValid_True() { NameValidator nameValidator = new NameValidator(10); Assert.True(nameValidator.IsNameValid("ValidName")); }
public void IsNameValid_NameHasInvalidCharacter_False() { NameValidator nameValidator = new NameValidator(5); Assert.False(nameValidator.IsNameValid("Invalid\'Name")); }
public void IsNameValid_NameIsLongerThanMaximalLength_False() { NameValidator nameValidator = new NameValidator(5); Assert.False(nameValidator.IsNameValid("LongName")); }
public void IsNameValid_NameIsEmpty_False() { NameValidator nameValidator = new NameValidator(5); Assert.False(nameValidator.IsNameValid(string.Empty)); }
public void IsNameValid_NameIsNull_False() { NameValidator nameValidator = new NameValidator(5); Assert.False(nameValidator.IsNameValid(null)); }