public async void Init(NavigationParameters parameters) { if (parameters != null) { if (parameters.Logout) { LogOutCommand.Execute(null); } CanGoBack = parameters.CanGoBack; ForegroundColor = parameters.ForegroundColor; BackgroundColor = parameters.BackgroundColor; if (!string.IsNullOrEmpty(parameters.Realm) && !string.IsNullOrEmpty(parameters.ServiceNamespace)) { _serviceListEndpoint = _identityProviderClient.GetDefaultIdentityProviderListServiceEndpoint(parameters.Realm, parameters.ServiceNamespace); } else { _serviceListEndpoint = _identityProviderClient.GetDefaultIdentityProviderListServiceEndpoint(); } } else { _serviceListEndpoint = _identityProviderClient.GetDefaultIdentityProviderListServiceEndpoint(); } await ReloadIdentityProviders(); }
private void DoLoginSelectedIdentity(DefaultIdentityProviderViewModel provider) { try { LogOutCommand.Execute(null); _loginIdentityProviderTask.LogIn(provider.LoginUrl, OnLoggedIn, AssumeCancelled, provider.Name, CanGoBack); } catch (Exception e) { if (LoginError != null) { LoginError(this, new LoginErrorEventArgs { Exception = e, Message = "An exception occured when attempting to log in." }); } } }
public string Dispatch(string input) { string[] arguments = input.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries); string commandName = arguments.Length > 0 ? arguments[0] : string.Empty; arguments = arguments.Skip(1).ToArray(); switch (commandName) { case "RegisterUser": RegisterUserCommand register = new RegisterUserCommand(authenticationManager); return(register.Execute(arguments)); case "Login": LogInCommand login = new LogInCommand(authenticationManager); return(login.Execute(arguments)); case "Logout": LogOutCommand logout = new LogOutCommand(authenticationManager); return(logout.Execute(arguments)); case "DeleteUser": DeleteUserCommand delete = new DeleteUserCommand(authenticationManager); return(delete.Execute(arguments)); case "CreateEvent": CreateEventCommand createEvent = new CreateEventCommand(authenticationManager); return(createEvent.Execute(arguments)); case "CreateTeam": CreateTeamCommand createTeam = new CreateTeamCommand(authenticationManager); return(createTeam.Execute(arguments)); case "InviteToTeam": InviteToTeamCommand inviteToTeam = new InviteToTeamCommand(authenticationManager); return(inviteToTeam.Execute(arguments)); case "AcceptInvite": AcceptInviteCommand acceptInvite = new AcceptInviteCommand(authenticationManager); return(acceptInvite.Execute(arguments)); case "DeclineInvite": DeclineInviteCommand declineInvite = new DeclineInviteCommand(authenticationManager); return(declineInvite.Execute(arguments)); case "KickMember": KickMemberCommand kickMember = new KickMemberCommand(authenticationManager); return(kickMember.Execute(arguments)); case "Disband": DisbandCommand disband = new DisbandCommand(authenticationManager); return(disband.Execute(arguments)); case "AddTeamTo": AddTeamToCommand addTeamToCommand = new AddTeamToCommand(authenticationManager); return(addTeamToCommand.Execute(arguments)); case "ShowEvent": ShowEventCommand showEvent = new ShowEventCommand(authenticationManager); return(showEvent.Execute(arguments)); case "ShowTeam": ShowTeamCommand showTeam = new ShowTeamCommand(authenticationManager); return(showTeam.Execute(arguments)); case "Exit": ExitCommand exitCommand = new ExitCommand(); return(exitCommand.Execute(arguments)); default: throw new NotSupportedException($"Command {commandName} is not supported!"); } }
public void ExecuteTest() { Assert.DoesNotThrow(() => { logOutCommandUnderTest.Execute(new object()); }); }
public string DispatchCommand(string[] commandParameters) { string command = commandParameters[0].ToLower(); User user = new User(); string result = null; using (PhotoShareContext context = new PhotoShareContext()) { switch (command) { case "registeruser": result = RegisterUserCommand.Execute(commandParameters); break; case "addtown": result = AddTownCommand.Execute(commandParameters); break; case "modifyuser": result = ModifyUserCommand.Execute(commandParameters); break; case "deleteuser": result = DeleteUser.Execute(commandParameters); break; case "addtag": result = AddTagCommand.Execute(commandParameters); break; case "addfriend": result = AddFriendCommand.Execute(commandParameters); break; case "acceptfriend": result = AcceptFriendCommand.Execute(commandParameters); break; case "createalbum": result = CreateAlbumCommand.Execute(commandParameters); break; case "uploadpicture": result = UploadPictureCommand.Execute(commandParameters); break; case "listfriends": result = PrintFriendsListCommand.Execute(commandParameters); break; case "addtagto": result = AddTagToCommand.Execute(commandParameters); break; case "sharealbum": result = ShareAlbumCommand.Execute(commandParameters); break; case "login": result = LoginCommand.Execute(commandParameters, context); break; case "logout": result = LogOutCommand.Execute(commandParameters, context); break; case "exit": result = ExitCommand.Execute(); break; default: throw new InvalidOperationException($"Command {command} not valid!"); } } return(result); }
public string DispatchCommand(string[] commandParameters) { var commands = commandParameters.Select(x => x.ToLower()).ToArray(); if (commands.Length == 5 && commands[0] == "registeruser") { return(RegisterUserCommand.Execute(commands)); } else if (commands[0] == "login" && commands.Length == 3) { return(LoginCommand.Execute(commands)); } if (commands.Length == 3 && commands[0] == "addtown") { return(AddTownCommand.Execute(commands)); } else if (commands.Length == 4 && commands[0] == "modifyuser") { return(ModifyUserCommand.Execute(commands)); } else if (commands.Length == 2 && commands[0] == "deleteuser") { return(DeleteUser.Execute(commands)); } else if (commands.Length == 2 && commands[0] == "addtag") { return(AddTagCommand.Execute(commands)); } else if (commands[0] == "createalbum" && commands.Length >= 5) { return(CreateAlbumCommand.Execute(commands)); } else if (commands[0] == "addtagto" && commands.Length == 3) { return(AddTagToCommand.Execute(commands)); } else if (commands[0] == "addfriend" && commands.Length == 3) { return(AddFriendCommand.Execute(commands)); } else if (commands[0] == "acceptfriend" && commands.Length == 3) { return(AcceptFriendCommand.Execute(commands)); } else if (commands[0] == "listfriends" && commands.Length == 2) { return(PrintFriendsListCommand.Execute(commands)); } else if (commands[0] == "sharealbum" && commands.Length == 4) { return(ShareAlbumCommand.Execute(commands)); } else if (commands[0] == "uploadpicture" && commands.Length == 4) { return(UploadPictureCommand.Execute(commands)); } else if (commands[0] == "logout" && commands.Length == 1) { return(LogOutCommand.Execute(commands)); } else if (commands[0] == "exit" && commands.Length == 1) { return(ExitCommand.Execute()); } return($"Command not valid!"); }
public string DispatchCommand(string[] commandParameters) { var command = commandParameters[0]; if (loggedInUserCommands.Contains(command) && Session.User == null) { throw new InvalidOperationException("Invalid credentials!"); } var args = commandParameters.Skip(1).ToArray(); var returnValue = ""; switch (command) { case "Login": returnValue = LogInCommand.Execute(args); break; case "RegisterUser": returnValue = RegisterUserCommand.Execute(args); break; case "ListFriends": returnValue = PrintFriendsListCommand.Execute(args); break; case "Logout": returnValue = LogOutCommand.Execute(args); break; case "AddTown": returnValue = AddTownCommand.Execute(args); break; case "ModifyUser": returnValue = ModifyUserCommand.Execute(args); break; case "DeleteUser": returnValue = DeleteUser.Execute(args); break; case "AddTag": returnValue = AddTagCommand.Execute(args); break; case "CreateAlbum": returnValue = CreateAlbumCommand.Execute(args); break; case "AddTagTo": returnValue = AddTagToCommand.Execute(args); break; case "AddFriend": returnValue = AddFriendCommand.Execute(args); break; case "AcceptFriend": returnValue = AcceptFriendCommand.Execute(args); break; case "ShareAlbum": returnValue = ShareAlbumCommand.Execute(args); break; case "UploadPicture": returnValue = UploadPictureCommand.Execute(args); break; case "Exit": returnValue = ExitCommand.Execute(); break; default: throw new InvalidOperationException($"Command {command} not valid!"); } return(returnValue); }