public void Commit_SingleChangeset_OutputsThatChangeset() { if (IsUsingPersistentClient) { Assert.Inconclusive("Hook tests does not function correctly under the persistent client"); return; } Repo.Init(); Repo.SetHook("commit"); File.WriteAllText(Path.Combine(Repo.Path, "test.txt"), "dummy"); Repo.Add("test.txt"); var command = new CustomCommand("commit") .WithAdditionalArgument("-m") .WithAdditionalArgument("dummy"); Repo.Execute(command); var tipHash = Repo.Tip().Hash; Assert.That(command.RawExitCode, Is.EqualTo(0)); Assert.That(command.RawStandardOutput, Is.StringContaining("LeftParentRevision:0000000000000000000000000000000000000000")); Assert.That(command.RawStandardOutput, Is.StringContaining("RightParentRevision:" + Environment.NewLine)); Assert.That(command.RawStandardOutput, Is.StringContaining("CommittedRevision:" + tipHash)); }
public void Pull_NoChangesets_DoesNotInvokeIncomingHook() { if (IsUsingPersistentClient) { Assert.Inconclusive("Hook tests does not function correctly under the persistent client"); return; } Repo1.Init(); Repo2.Clone(Repo1.Path); WriteTextFileAndCommit(Repo1, "test.txt", "dummy", "dummy", true); Repo2.Pull(Repo1.Path); Repo2.SetHook("changegroup"); var command = new CustomCommand("pull") .WithAdditionalArgument(string.Format(CultureInfo.InvariantCulture, "\"{0}\"", Repo1.Path)); Repo2.Execute(command); Assert.That(command.RawExitCode, Is.EqualTo(0)); Assert.That(command.RawStandardOutput, Is.Not.StringContaining("Revision:")); Assert.That(command.RawStandardOutput, Is.Not.StringContaining("Url:")); Assert.That(command.RawStandardOutput, Is.Not.StringContaining("Source:")); }
public void Commit_HookThatFails_DoesNotAllowCommit() { if (IsUsingPersistentClient) { Assert.Inconclusive("Hook tests does not function correctly under the persistent client"); return; } Repo.SetHook("pre-commit", "fail"); var command = new CustomCommand("commit") .WithAdditionalArgument("-m") .WithAdditionalArgument("dummy"); Assert.Throws<MercurialExecutionException>(() => Repo.Execute(command)); Assert.That(command.RawExitCode, Is.Not.EqualTo(0)); Assert.That(Repo.Log().Count(), Is.EqualTo(0)); }
public void Commit_HookThatPasses_AllowsCommit() { if (IsUsingPersistentClient) { Assert.Inconclusive("Hook tests does not function correctly under the persistent client"); return; } Repo.SetHook("pre-commit", "ok"); var command = new CustomCommand("commit") .WithAdditionalArgument("-m") .WithAdditionalArgument("dummy"); Repo.Execute(command); Assert.That(command.RawExitCode, Is.EqualTo(0)); Assert.That(Repo.Log().Count(), Is.EqualTo(1)); }
/// <summary> /// Register a new ADV scripting command. The name of the command will be inferred based on the type's name. /// </summary> /// <typeparam name="T">The type of the command.</typeparam> /// <returns>The Command ID of the custom command.</returns> public static Command RegisterCustomCommand <T>(BaseUnityPlugin owner) where T : CommandBase { KeyValuePair <Command, CustomCommand> first = new KeyValuePair <Command, CustomCommand>(); foreach (var pair in InjectedCommands) { if (pair.Value.Type == typeof(T)) { KoikatuAPI.Logger.LogWarning($"Attempted to inject command {typeof(T).FullName} again."); return(pair.Value.ID); } } Command newCommand = (Command)_nextFreeCommandID; InjectedCommands[newCommand] = new CustomCommand(newCommand, typeof(T), owner); KoikatuAPI.Logger.LogDebug($"Injected command {typeof(T).FullName} with ID {newCommand}."); _nextFreeCommandID++; return(newCommand); }
public void Pull_NoChangesets_DoesNotInvokeIncomingHook() { Repo1.Init(); Repo2.Clone(Repo1.Path); WriteTextFileAndCommit(Repo1, "test.txt", "dummy", "dummy", true); Repo2.Pull(Repo1.Path); Repo2.SetHook("changegroup"); var command = new CustomCommand("pull") .WithAdditionalArgument(string.Format(CultureInfo.InvariantCulture, "\"{0}\"", Repo1.Path)); Repo2.Execute(command); Assert.That(command.RawExitCode, Is.EqualTo(0)); Assert.That(command.RawStandardOutput, Is.Not.Contains("Revision:")); Assert.That(command.RawStandardOutput, Is.Not.Contains("Url:")); Assert.That(command.RawStandardOutput, Is.Not.Contains("Source:")); }
public TreasureDefenseGameEditorControlViewModel(TreasureDefenseGameCommand command) { this.existingCommand = command; this.MinimumParticipants = this.existingCommand.MinimumParticipants; this.TimeLimit = this.existingCommand.TimeLimit; this.ThiefPlayerPercentage = this.existingCommand.ThiefPlayerPercentage; this.StartedCommand = this.existingCommand.StartedCommand; this.UserJoinCommand = this.existingCommand.UserJoinCommand; this.NotEnoughPlayersCommand = this.existingCommand.NotEnoughPlayersCommand; this.KnightUserCommand = this.existingCommand.KnightUserCommand; this.ThiefUserCommand = this.existingCommand.ThiefUserCommand; this.KingUserCommand = this.existingCommand.KingUserCommand; this.KnightSelectedCommand = this.existingCommand.KnightSelectedCommand; this.ThiefSelectedCommand = this.existingCommand.ThiefSelectedCommand; }
public List <Domain.Entity.Region> SearchRegions(string filter, int regionType) { try { var command = new CustomCommand { CommandType = CommandType.StoredProcedure, Parameters = new DynamicParameters() }; command.Parameters.Add("filter", filter, DbType.String); command.Parameters.Add("type", regionType, DbType.Int32); command.SqlCommand = "dbo.SearchRegions"; return(GetAll(command, new RegionRowMapper()).ToList()); } catch (Exception ex) { Logger.ErrorException(ex.Message, ex); throw ex; } }
private void InitializeMissingData() { this.GameQueueUserJoinedCommand = this.GameQueueUserJoinedCommand ?? CustomCommand.BasicChatCommand("Game Queue Used Joined", "You are #$queueposition in the queue to play."); this.GameQueueUserSelectedCommand = this.GameQueueUserSelectedCommand ?? CustomCommand.BasicChatCommand("Game Queue Used Selected", "It's time to play @$username! Listen carefully for instructions on how to join..."); this.GiveawayStartedReminderCommand = this.GiveawayStartedReminderCommand ?? CustomCommand.BasicChatCommand("Giveaway Started/Reminder", "A giveaway has started for $giveawayitem! Type $giveawaycommand in chat in the next $giveawaytimelimit minute(s) to enter!"); this.GiveawayUserJoinedCommand = this.GiveawayUserJoinedCommand ?? CustomCommand.BasicChatCommand("Giveaway User Joined"); this.GiveawayWinnerSelectedCommand = this.GiveawayWinnerSelectedCommand ?? CustomCommand.BasicChatCommand("Giveaway Winner Selected", "Congratulations @$username, you won $giveawayitem!"); this.ModerationStrike1Command = this.ModerationStrike1Command ?? CustomCommand.BasicChatCommand("Moderation Strike 1", "$moderationreason. You have received a moderation strike & currently have $usermoderationstrikes strike(s)", isWhisper: true); this.ModerationStrike2Command = this.ModerationStrike2Command ?? CustomCommand.BasicChatCommand("Moderation Strike 2", "$moderationreason. You have received a moderation strike & currently have $usermoderationstrikes strike(s)", isWhisper: true); this.ModerationStrike3Command = this.ModerationStrike3Command ?? CustomCommand.BasicChatCommand("Moderation Strike 3", "$moderationreason. You have received a moderation strike & currently have $usermoderationstrikes strike(s)", isWhisper: true); if (this.DashboardItems.Count < 4) { this.DashboardItems = new List <DashboardItemTypeEnum>() { DashboardItemTypeEnum.None, DashboardItemTypeEnum.None, DashboardItemTypeEnum.None, DashboardItemTypeEnum.None }; } if (this.DashboardQuickCommands.Count < 5) { this.DashboardQuickCommands = new List <Guid>() { Guid.Empty, Guid.Empty, Guid.Empty, Guid.Empty, Guid.Empty }; } if (this.GetCustomCommand(this.RedemptionStoreManualRedeemNeededCommandID) == null) { CustomCommand command = CustomCommand.BasicChatCommand(RedemptionStorePurchaseModel.ManualRedemptionNeededCommandName, "@$username just purchased $productname and needs to be manually redeemed"); this.RedemptionStoreManualRedeemNeededCommandID = command.ID; this.SetCustomCommand(command); } if (this.GetCustomCommand(this.RedemptionStoreDefaultRedemptionCommandID) == null) { CustomCommand command = CustomCommand.BasicChatCommand(RedemptionStorePurchaseModel.DefaultRedemptionCommandName, "@$username just redeemed $productname"); this.RedemptionStoreDefaultRedemptionCommandID = command.ID; this.SetCustomCommand(command); } }
public DesktopChannelSettings(ExpandedChannelModel channel, bool isStreamer = true) : this() { this.Channel = channel; this.IsStreamer = isStreamer; this.GameQueueUserJoinedCommand = CustomCommand.BasicChatCommand("Game Queue Used Joined", "You are #$queueposition in the queue to play.", isWhisper: true); this.GameQueueUserSelectedCommand = CustomCommand.BasicChatCommand("Game Queue Used Selected", "It's time to play @$username! Listen carefully for instructions on how to join..."); this.GiveawayStartedReminderCommand = CustomCommand.BasicChatCommand("Giveaway Started/Reminder", "A giveaway has started for $giveawayitem! Type $giveawaycommand in chat in the next $giveawaytimelimit minute(s) to enter!"); this.GiveawayUserJoinedCommand = CustomCommand.BasicChatCommand("Giveaway User Joined", "You have been entered into the giveaway, stay tuned to see who wins!", isWhisper: true); this.GiveawayWinnerSelectedCommand = CustomCommand.BasicChatCommand("Giveaway Winner Selected", "Congratulations @$username, you won $giveawayitem!"); this.SongAddedCommand = CustomCommand.BasicChatCommand("Song Request Added", "$songtitle has been added to the queue", isWhisper: true); this.SongRemovedCommand = CustomCommand.BasicChatCommand("Song Request Removed", "$songtitle has been removed from the queue", isWhisper: true); this.SongPlayedCommand = CustomCommand.BasicChatCommand("Song Request Played", "Now Playing: $songtitle"); this.ModerationStrike1Command = CustomCommand.BasicChatCommand("Moderation Strike 1", "$moderationreason. You have received a moderation strike & currently have $usermoderationstrikes strike(s)", isWhisper: true); this.ModerationStrike2Command = CustomCommand.BasicChatCommand("Moderation Strike 2", "$moderationreason. You have received a moderation strike & currently have $usermoderationstrikes strike(s)", isWhisper: true); this.ModerationStrike3Command = CustomCommand.BasicChatCommand("Moderation Strike 3", "$moderationreason. You have received a moderation strike & currently have $usermoderationstrikes strike(s)", isWhisper: true); }
public BeachBallGameEditorControlViewModel(BeachBallGameCommand command) { this.existingCommand = command; #pragma warning disable CS0612 // Type or member is obsolete if (this.existingCommand.HitTimeLimit > 0) { this.existingCommand.LowerLimit = this.existingCommand.HitTimeLimit; this.existingCommand.UpperLimit = this.existingCommand.HitTimeLimit; this.existingCommand.HitTimeLimit = 0; } #pragma warning restore CS0612 // Type or member is obsolete this.LowerTimeLimit = this.existingCommand.LowerLimit; this.UpperTimeLimit = this.existingCommand.UpperLimit; this.AllowUserTargeting = this.existingCommand.AllowUserTargeting; this.StartedCommand = this.existingCommand.StartedCommand; this.BallHitCommand = this.existingCommand.BallHitCommand; this.BallMissedCommand = this.existingCommand.BallMissedCommand; }
public void TestCustomCommand_CanExecute() { var fact = Substitute.For <CustomCommandFactory>(); CustomCommand cmd = fact.Create() as CustomCommand; Assert.IsNotNull(cmd); object arg1 = null; bool ret1 = cmd.CanExecute(arg1); bool expected1 = false; Assert.IsFalse(ret1); Assert.AreEqual(expected1, ret1); object arg2 = new Object(); bool ret2 = cmd.CanExecute(arg2); bool expected2 = true; Assert.IsTrue(ret2); Assert.AreEqual(expected2, ret2); }
public HotPotatoGameEditorControlViewModel(HotPotatoGameCommand command) { this.existingCommand = command; #pragma warning disable CS0612 // Type or member is obsolete if (this.existingCommand.TimeLimit > 0) { this.existingCommand.LowerLimit = this.existingCommand.TimeLimit; this.existingCommand.UpperLimit = this.existingCommand.TimeLimit; this.existingCommand.TimeLimit = 0; } #pragma warning restore CS0612 // Type or member is obsolete this.LowerTimeLimit = this.existingCommand.LowerLimit; this.UpperTimeLimit = this.existingCommand.UpperLimit; this.AllowUserTargeting = this.existingCommand.AllowUserTargeting; this.StartedCommand = this.existingCommand.StartedCommand; this.TossPotatoCommand = this.existingCommand.TossPotatoCommand; this.PotatoExplodeCommand = this.existingCommand.PotatoExplodeCommand; }
public async Task Add(CustomCommand value) { try { Context.CustomCommands.Add(value); await Context.SaveChangesAsync(); } catch (DbUpdateException e) { Exception exception = e; while (exception.InnerException != null) { exception = exception.InnerException; } if (exception.Message.Contains("Duplicate entry")) { throw new ItemExistsException("the item already exists in the database."); } } }
private void LoadCommands() { LoginCommand = new CustomCommand(o => { PAVContext context = new PAVContext(); var usuario = context.Usuarios.Where(u => u.NombreUsuario == Usuario && u.Clave == Clave) .Include(u => u.Persona) .FirstOrDefault(); if (usuario != null) { MessageBox.Show($"Bienvenido {usuario.Persona.Nombre} {usuario.Persona.Apellido}"); } else { MessageBox.Show("Credenciales incorrectas"); } Console.WriteLine("Iniciar Sesion presionado"); }, CanExecuteLogin); }
public LiveStreamViewModel(BusinessLogic businessLogic) : base(businessLogic) { if (!businessLogic.IsAuthenticated()) { if (!businessLogic.Login(Properties.user.Default.UseServiceLayer)) { return; } } CloseCommand = new CustomCommand(CloseWindow, CanCloseWindow); BigScreenCommand = new CustomCommand(BigScreen, CanBigScreen); LoadCamerasInfo(); Messenger.Default.Register <UseServerLayerMessage> ( this, (action) => LoadCamerasInfo() ); }
public override void SetItem(OverlayItemBase item) { this.item = (OverlayTimer)item; this.TotalLengthTextBox.Text = this.item.TotalLength.ToString(); this.TextColorComboBox.Text = this.item.TextColor; if (ColorSchemes.ColorSchemeDictionary.ContainsValue(this.item.TextColor)) { this.TextColorComboBox.Text = ColorSchemes.ColorSchemeDictionary.FirstOrDefault(c => c.Value.Equals(this.item.TextColor)).Key; } this.TextFontComboBox.Text = this.item.TextFont; this.TextSizeComboBox.Text = this.item.TextSize.ToString(); this.HTMLText.Text = this.item.HTMLText; this.command = this.item.TimerCompleteCommand; this.UpdateChangedCommand(); }
private static async Task Version32Upgrade(int version, string filePath) { if (version < 32) { DesktopChannelSettings settings = await SerializerHelper.DeserializeFromFile <DesktopChannelSettings>(filePath); await ChannelSession.Services.Settings.Initialize(settings); settings.SongRemovedCommand = CustomCommand.BasicChatCommand("Song Request Removed", "$songtitle has been removed from the queue", isWhisper: true); foreach (GameCommandBase command in settings.GameCommands.ToList()) { if (command is BetGameCommand) { settings.GameCommands.Remove(command); } } await ChannelSession.Services.Settings.Save(settings); } }
private async Task AddNewCommand() { var cmnd = new CustomCommand(); var dialog = new CustomCommandAddDialog { DataContext = cmnd }; var result = (bool)await DialogHost.Show(dialog); if (result && !string.IsNullOrWhiteSpace(cmnd.Name) && !string.IsNullOrWhiteSpace(cmnd.Channel) && !string.IsNullOrWhiteSpace(cmnd.Message)) { await _context.CustomCommands.AddAsync(cmnd); await _context.SaveChangesAsync(); CustomCommands.Add(cmnd); } }
public void Commit_SingleChangeset_OutputsThatChangeset() { Repo.Init(); Repo.SetHook("commit"); File.WriteAllText(Path.Combine(Repo.Path, "test.txt"), "dummy"); Repo.Add("test.txt"); var command = new CustomCommand("commit") .WithAdditionalArgument("-m") .WithAdditionalArgument("dummy"); Repo.Execute(command); var tipHash = Repo.Tip().Hash; Assert.That(command.RawExitCode, Is.EqualTo(0)); Assert.That(command.RawStandardOutput, Contains.Substring("LeftParentRevision:0000000000000000000000000000000000000000")); Assert.That(command.RawStandardOutput, Contains.Substring("RightParentRevision:" + Environment.NewLine)); Assert.That(command.RawStandardOutput, Contains.Substring("CommittedRevision:" + tipHash)); }
public bool IsHoliday(DateTime date) { IDataReader dr = null; bool res = false; try { var command = new CustomCommand { CommandType = CommandType.StoredProcedure, Parameters = new DynamicParameters() }; command.Parameters.Add("date", date, DbType.Date); command.SqlCommand = "shd.IsHoliday"; dr = Session.ExecuteReader(new CommandDefinition(command.SqlCommand, command.Parameters, commandType: command.CommandType)); if (dr.Read()) { var isHoliday = dr[0].SafeInt(); if (isHoliday == 1) { res = true; } } return(res); } catch (Exception ex) { Logger.ErrorException(ex.Message, ex); throw ex; } finally { if (dr != null) { dr.Dispose(); dr.Close(); } } }
protected override Task OnLoaded() { if (this.existingCommand != null) { this.CommandDetailsControl.SetDefaultValues(this.existingCommand); this.CommandDetailsControl.SetDefaultValues(this.existingCommand); this.MinimumAmountForPayoutTextBox.Text = this.existingCommand.MinimumAmountForPayout.ToString(); this.PayoutProbabilityTextBox.Text = this.existingCommand.PayoutProbability.ToString(); this.PayoutPercentageMinimumLimitTextBox.Text = (this.existingCommand.PayoutPercentageMinimum * 100).ToString(); this.PayoutPercentageMaximumLimitTextBox.Text = (this.existingCommand.PayoutPercentageMaximum * 100).ToString(); this.noPayoutCommand = this.existingCommand.NoPayoutCommand; this.payoutCommand = this.existingCommand.PayoutCommand; this.StatusArgumentTextBox.Text = this.existingCommand.StatusArgument; this.statusCommand = this.existingCommand.StatusCommand; } else { this.CommandDetailsControl.SetDefaultValues("Coin Pusher", "pusher", CurrencyRequirementTypeEnum.MinimumAndMaximum, 10, 1000); UserCurrencyViewModel currency = ChannelSession.Settings.Currencies.Values.FirstOrDefault(); this.MinimumAmountForPayoutTextBox.Text = "2500"; this.PayoutProbabilityTextBox.Text = "10"; this.PayoutPercentageMinimumLimitTextBox.Text = "30"; this.PayoutPercentageMaximumLimitTextBox.Text = "70"; this.noPayoutCommand = this.CreateBasicChatCommand("@$username drops their coins into the machine...and nothing happens. All $gametotalamount " + currency.Name + " stares back at you."); this.payoutCommand = this.CreateBasicChatCommand("@$username drops their coins into the machine...and hits the jackpot, walking away with $gamepayout " + currency.Name + "!"); this.StatusArgumentTextBox.Text = "status"; this.statusCommand = this.CreateBasicChatCommand("After spending a few minutes, you count $gametotalamount " + currency.Name + " inside the machine."); } this.NoPayoutCommandButtonsControl.DataContext = this.noPayoutCommand; this.PayoutCommandButtonsControl.DataContext = this.payoutCommand; this.StatusCommandButtonsControl.DataContext = this.statusCommand; return(base.OnLoaded()); }
public StudentsViewModel() { Service.ReadAsync().ContinueWith(x => { Students = new ObservableCollection <Student>(x.Result); PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(Students))); }); //DeleteCommand = new CustomCommand(x => Students.Remove(SelectedStudent), x => SelectedStudent != null); DeleteCommand = new CustomCommand(async x => { try { await Service.DeleteAsync(SelectedStudent.Id); Students.Remove(SelectedStudent); } catch { MessageBox.Show("Usuwanie nie powiodło się", "Błąd", MessageBoxButton.OK, MessageBoxImage.Error); } }, x => SelectedStudent != null); }
public bool IsPartyBoardMember(long partyId) { IDataReader dr = null; bool res = false; try { var command = new CustomCommand { CommandType = CommandType.StoredProcedure, Parameters = new DynamicParameters(), SqlCommand = "pm.IsPartyBoardMember" }; command.Parameters.Add("partyId", partyId, DbType.Int16); dr = Session.ExecuteReader(new CommandDefinition(command.SqlCommand, command.Parameters, commandType: command.CommandType)); if (dr.Read()) { var id = dr[0].SafeInt(); if (id > 0) { res = true; } } return(res); } catch (Exception ex) { Logger.ErrorException(ex.Message, ex); throw ex; } finally { if (dr != null) { dr.Dispose(); dr.Close(); } } }
public Domain.Entity.PartyBankAccount GetPartyBankAccount(long partyId, string accountNumber, int bankId) { try { var command = new CustomCommand { CommandType = CommandType.StoredProcedure, Parameters = new DynamicParameters() }; command.Parameters.Add("partyId", partyId, DbType.Int64); command.Parameters.Add("accountNumber", accountNumber, DbType.String); command.Parameters.Add("bankId", bankId, DbType.Int32); command.SqlCommand = "pm.GetPartyBankAccount"; return(Get(command, new PartyBankAccountRowMapper())); } catch (Exception ex) { Logger.ErrorException(ex.Message, ex); throw ex; } }
/// <summary> /// /// </summary> /// <param name="serviceSetting">Настройки</param> /// <param name="textSearch">Текст поиска</param> /// <param name="searchAction">Делегат для поиска по tag</param> public ViewModelMorePhoto(IServiceSetting serviceSetting, Func <object, Task> searchAction, ServiceNavigation serviceNavigation) { this.serviceSetting = serviceSetting; this.searchAction = searchAction; this.serviceNavigation = serviceNavigation; CommandSelectImage = new CustomCommand(Executed_SelectImage, CanExecut_CommandSelectImage); CommandNextImage = new CustomCommand(Executed_NextImage); CommandBackImage = new CustomCommand(Executed_BackImage); CommandNextPageImage = new CustomCommand(Executed_NextPageImage); CommandLostConnect = new CustomCommand(Executed_LostConnect); CommandSearch = new AsyncCommand(searchAction); //CommandManager.RegisterClassInputBinding(typeof(ViewModelMorePhoto), // new InputBinding(CommandNextImage, new KeyGesture(Key.Right))); //CommandManager.RegisterClassInputBinding(typeof(ViewModelMorePhoto), // new InputBinding(CommandBackImage, new KeyGesture(Key.Left))); // Task.Factory.StartNew(() => SearchByText(textSearch)); }
public Task <Result> Execute(SocketUserMessage e, string name) { IEnumerable <Command> cmd = customSet.commandsInSet.Where(x => x.command == name); if (cmd.Count() > 0) { CustomCommand custom = cmd.First() as CustomCommand; if (custom.owner == e.Author.Id || (custom.owner == 0 && (e.Author as SocketGuildUser).GuildPermissions.ManageGuild)) { DeleteCommand(custom, customSet); return(TaskResult(null, "Succesfully removed command " + custom.command + ".")); } else { return(TaskResult(null, "Error - Access to command denied.")); } } else { return(TaskResult(null, "Error - Command " + name + " not found.")); } }
public async Task Return_IsValid_GivenValidCustomCommand() { // Arrange var services = new ServiceCollection(); services.AddSimpleCommandsPlugin(); var command = new CustomCommand { CommandWord = "!ping", Response = "PONG!", Access = Access.Everyone, CooldownTime = 0, UserCooldownTime = 0, }; // Act var result = await services.BuildServiceProvider().GetRequiredService <ICustomCommandValidator>().ValidateAsync(command).ConfigureAwait(false); // Assert result.IsValid.Should().BeTrue(); }
public AlarmListWindowViewModel(BusinessLogic businessLogic) : base(businessLogic) { if (!businessLogic.IsAuthenticated()) { if (!businessLogic.Login(Properties.user.Default.UseServiceLayer)) { return; } } // _dialogueService = new DialogueService(); ConnectionCommand = new CustomCommand(ConnectionInfo, CanConnectionInfoCommand); CloseCommand = new CustomCommand(Close, CanCloseCommand); SystemCommand = new CustomCommand(SystemInfo, CanSystemInfoCommand); ImageCommand = new CustomCommand(LiveImage, CanLiveImageCommand); StreamCommand = new CustomCommand(LiveStream, CanLiveStreamCommand); AudioCommand = new CustomCommand(GiveAudioStream, CanGiveAudioStreamCommand); VideoCommand = new CustomCommand(RecordedVideo, CanRecordedVideoCommand); LoadAllAlarms(); }
public MainVM() { ideaStatiCaDir = Properties.Settings.Default.IdeaStatiCaDir; if (Directory.Exists(ideaStatiCaDir)) { string ideaConnectionFileName = Path.Combine(ideaStatiCaDir, "IdeaConnection.exe"); if (File.Exists(ideaConnectionFileName)) { IsIdea = true; StatusMessage = string.Format("IdeaStatiCa installation was found in '{0}'", ideaStatiCaDir); } } if (!IsIdea) { StatusMessage = string.Format("ERROR IdeaStatiCa doesn't exist in '{0}'", ideaStatiCaDir); } RunIdeaConnectionCmd = new CustomCommand(this.CanRunIdeaConnection, this.RunIdeaConnection); OpenProjectCmd = new CustomCommand(this.CanOpenProject, this.OpenProject); CloseProjectCmd = new CustomCommand(this.CanCloseProject, this.CloseProject); }
public DetailViewModel() { //OK-Command (Bestätigung) this.OkCmd = new CustomCommand ( //CanExe: Kann immer ausgeführt werden. Eine Prüfung auf die Validierung der einzelnen EIngabefelder findet schon in der GUI (vgl. DetailView) statt. para => true, //Exe: para => { //Erstellung des Strings für die MessageBox Model.Person person = this.AktuellePerson; string ausgabe = $"{person.Vorname} {person.Nachname} ({person.Geschlecht})\n{person.Geburtsdatum.ToShortDateString()}\n{person.Lieblingsfarbe}\n"; if (person.Verheiratet) { ausgabe += "Ist Verheiratet\n"; } ausgabe += "Abspeichern?"; //Nachfrage auf Korrektheit der Daten per MessageBox if (MessageBox.Show(ausgabe, $"{person.Vorname} {person.Nachname}", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { //Setzen des DialogResults des Views (welches per Parameter übergeben wurde) auf true, damit das LIstView weiß, dass es weiter //machen kann (d.h. die neuen Person einfügen bzw. austauschen) (para as View.DetailView).DialogResult = true; //Schließen des Views (para as View.DetailView).Close(); } } ); //Abbruch-Cmd this.AbbruchCmd = new CustomCommand ( //CanExe: Kann immer ausgeführt werden para => true, //Exe: Schließen des Fensters para => (para as View.DetailView).Close() );; }
public SIOnlineViewModel(ConnectionData connectionData, IGameServerClient gameServerclient, CommonSettings commonSettings, UserSettings userSettings) : base(connectionData, commonSettings, userSettings) { _gameServerClient = gameServerclient; _gameServerClient.GameCreated += GameServerClient_GameCreated; _gameServerClient.GameDeleted += GameServerClient_GameDeleted; _gameServerClient.GameChanged += GameServerClient_GameChanged; _gameServerClient.Joined += GameServerClient_Joined; _gameServerClient.Leaved += GameServerClient_Leaved; _gameServerClient.Receieve += OnMessage; _gameServerClient.Reconnecting += GameServerClient_Reconnecting; _gameServerClient.Reconnected += GameServerClient_Reconnected; _gameServerClient.Closed += GameServerClient_Closed; _gameServerClient.UploadProgress += GameServerClient_UploadProgress; ServerAddress = _gameServerClient.ServerAddress; AddEmoji = new CustomCommand(AddEmoji_Executed); }
public async Task Remove(CustomCommand value) { try { Context.CustomCommands.Remove(value); await Context.SaveChangesAsync(); } catch (DbUpdateException e) { Exception exception = e; while (exception.InnerException != null) { exception = exception.InnerException; } if (exception.Message.Contains( "Database operation expected to affect 1 row(s) but actually affected 0 row(s).")) { throw new InvalidItemException("the item does not exist in the database."); } } }
public AppViewModel(ILoadingDialogService loadingService, IAboutDialogService aboutService) { AboutService = aboutService; LoadingService = loadingService; _currentView = new IntroPageViewModel(); _mutex = new AutoResetEvent(false); _worker = new BackgroundWorker() { WorkerReportsProgress = true, WorkerSupportsCancellation = true, }; _worker.DoWork += BackgroundWorker_DoWork; _worker.RunWorkerCompleted += BackgroundWorker_RunWorkerCompleted; _worker.ProgressChanged += BackgroundWorker_ProgressChanged; AboutCommand = new CustomCommand(AboutCommand_CanExecute, AboutCommand_Execute); FinishStep = new CustomCommand(FinishStep_CanExecute, FinishStep_Execute); NextStep = new CustomCommand(NextStep_CanExecute, NextStep_Execute); PrevStep = new CustomCommand(PrevStep_CanExecute, PrevStep_Execute); }
public DataSourceFileService([CreateDataSourceFileCommandAttribute]CustomCommand createDatatSourceFileCommand, IDataSourceFileReadRepository dataSourceFileReadRepository) { _createDataSourceFileCommand = createDatatSourceFileCommand; DataSourceFileReadRepository = dataSourceFileReadRepository; }
public DurationBox() { SetDurationMinutesCommand = new CustomCommand(this); }
public void Handle(CustomCommand obj) { EvaluatorValue = new CustomCommand(obj.CommandValue); }
private CommandHandler(CustomCommand<CommandType, UserType, DelayType> command) { Name = command.Name.ToLower(); Access = command.Access; DelayType = command.CooldownType; Handler = (e, userModel) => CustomCommandHandler.CreateCommand(command, e, userModel.Channel); Cooldown = command.CooldownTime; }
public TimeBox() { SetTimeCommand = new CustomCommand(this); }
public DataFileConfigurationService([CreateDataFileConfigurationCommandAttribute]CustomCommand createDFCCommand, IDataFileConfigurationReadRepository repository) { _createDFCCommand = createDFCCommand; DataFileConfigurationReadRepository = repository; }
internal GeminiCommand(ResultType type, int chars, bool bUpdateStatus, CustomCommand cmdDelegate) : this(type, chars, bUpdateStatus) { CustomDelegate = cmdDelegate; }
internal Statement(ParseNode parent, Parser p) : base(parent, p) { if (Block.CanParse(p)) { type = Type.Block; block = new Block(this, p); return; } else if (IfStatement.CanParse(p)) { type = Type.IfStatement; ifStatement = new IfStatement(this, p); return; } else if (OptionStatement.CanParse(p)) { type = Type.OptionStatement; optionStatement = new OptionStatement(this, p); return; } else if (AssignmentStatement.CanParse(p)) { type = Type.AssignmentStatement; assignmentStatement = new AssignmentStatement(this, p); return; } else if (ShortcutOptionGroup.CanParse(p)) { type = Type.ShortcutOptionGroup; shortcutOptionGroup = new ShortcutOptionGroup(this, p); return; } else if (CustomCommand.CanParse(p)) { type = Type.CustomCommand; customCommand = new CustomCommand(this, p); return; } else if (p.NextSymbolIs(TokenType.Text)) { line = p.ExpectSymbol(TokenType.Text).value as string; type = Type.Line; } else { throw ParseException.Make(p.tokens.Peek(), "Expected a statement here but got " + p.tokens.Peek().ToString() +" instead (was there an unbalanced if statement earlier?)"); } }