/// <summary> /// Invokes a stored procedure /// </summary> /// <param name="name">name of the stored procedure</param> /// <param name="prms">parameters object</param> public void Invoke(string name, object prms = null) { using (var cmd = _commandFactory.Create(name, prms, true)) { Mapper.ExecuteNonQuery(cmd); } }
public IObservable <UniRx.Unit> Run() { IUnitData[] unitDatas = _unitSpawnSettings.GetUnits(_data.unitCommandData.UnitType); if (_data.unitCommandData.UnitIndex >= unitDatas.Length) { string errorMsg = string.Format("Unit Index not in unit datas range: {0}", _data.unitCommandData.UnitIndex); _logger.LogError(LoggedFeature.Units, errorMsg); return(Observable.Throw <UniRx.Unit>(new IndexOutOfRangeException(errorMsg))); } IUnitData unitData = unitDatas[(int)_data.unitCommandData.UnitIndex]; // First, spawn the pets recursively. // We create commands that we execute directly, because // we don't want to treat these as standalone commands (they are only ever children of this command) IUnit[] pets = new IUnit[_data.unitCommandData.pets.Length]; for (var i = 0; i < _data.unitCommandData.pets.Length; i++) { SpawnUnitData petSpawnUnitData = new SpawnUnitData(_data.unitCommandData.pets[i], _data.tileCoords, _data.isInitialSpawn); ICommand petSpawnCommand = _commandFactory.Create(typeof(SpawnUnitCommand), typeof(SpawnUnitData), petSpawnUnitData); petSpawnCommand.Run(); pets[i] = _unitRegistry.GetUnit(_data.unitCommandData.pets[i].unitId); } // Now, spawn the unit itself. IUnit unit = _unitPool.Spawn(_data.unitCommandData.unitId, unitData, pets); _gridUnitManager.PlaceUnitAtTile(unit, _data.tileCoords); _logger.Log(LoggedFeature.Units, "Spawned: {0}. Id: {1}", unitData.Name, unit.UnitId); return(Observable.ReturnUnit()); }
public ConfirmationDialogViewModel(ICommandFactory commandFactory, IMessenger messenger) { this.messenger = messenger; OkButtonClick = commandFactory.Create(OnOkButtonClick); CancelButtonClick = commandFactory.Create(OnCancelButtonClick, (o) => IsOkCancelMode); }
public PasswordGenerationViewModel( ICommandFactory commandFactory, IMessenger messenger, IGenerator <string, PasswordGenerationParameters> generator) { this.messenger = messenger; this.generator = generator; ConfirmButtonClick = commandFactory.Create(OnConfirmButtonClick); BackButtonClick = commandFactory.Create(OnBackButtonClick); GenerateButtonClick = commandFactory.Create(OnGenerateButtonClick); LengthValues = new List <int>(); PopulateLength(); Parameters = new PasswordGenerationParameters { Length = LengthValues.Find(x => x == 16), IncludeSpecialCharacters = false, IncludeNumericCharacters = true, IncludeLowerCaseCharacters = true, IncludeUpperCaseCharacters = true, ExcludeSimilarCharacters = true, ExcludeAmbiguousCharacters = true }; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Parameters))); }
public void AddBike(string name, decimal hourCost) { _commandFactory.Create <AddNewBikeCommandContext>().Execute( new AddNewBikeCommandContext() { HourCost = hourCost, Name = name }); }
public AuthenticationViewModel(IUserService userService, ICommandFactory commandFactory, IMessenger messenger) { this.userService = userService; this.messenger = messenger; RegisterButtonClick = commandFactory.Create(OnRegistrationButtonClick); LogInButtonClick = commandFactory.Create(OnLogInButtonClick); AddValidation(); }
public AccountFormViewModel(IUserService userService, ICommandFactory commandFactory, IMessenger messenger) { this.userService = userService; this.messenger = messenger; SaveButtonClick = commandFactory.Create(OnSaveButtonClick); BackButtonClick = commandFactory.Create(OnBackButtonClick); GenerateButtonClick = commandFactory.Create(OnGenerateButtonClick); AddValidation(); }
public void AddEmployee(AddEmployeeParameters parameters) { if (parameters.NewEmployee == null) { throw new InvalidParameterException(); } var addEmployeeCommand = commandFactory.Create <AddEmployeeCommand>(); addEmployeeCommand.Execute(parameters.NewEmployee, parameters.Dependents); }
private void OnStateChangeRequested <T>(SetupSecurityRequestMessage <T> message) { BackButtonClick = commandFactory.Create((obj) => { OnBackButtonClick(message); }); ConfirmButtonClick = commandFactory.Create((obj) => { OnConfirmButtonClick(message); }); }
public TResult Execute <TCriteria, TResult>(TCriteria criteria) { var command = _commandFactory.Create <ICommand <TCriteria, TResult> >(); try { return(command.Execute(criteria)); } finally { _commandFactory.Release(command); } }
public KeyChangeViewModel(IUserService userService, ICommandFactory commandFactory, IMessenger messenger) { this.userService = userService; this.messenger = messenger; SaveButtonClick = commandFactory.Create(OnSaveButtonClick); SecuritySettingsButtonClick = commandFactory.Create(OnSecuritySettingsButtonClick); BackButtonClick = commandFactory.Create(OnBackButtonClick); storageProvider = new DefaultStorageProvider(); AddValidation(); }
public SecuritySettingsViewModel(ICommandFactory commandFactory, IMessenger messenger, IViewModelFactory viewModelFactory) { this.commandFactory = commandFactory; this.messenger = messenger; this.viewModelFactory = viewModelFactory; storageProvider = new ConfigurableStorageProvider(); RunOneSecondSetupButtonClick = commandFactory.Create(OnRunOneSecondSetupButtonClickAsync); RunTestButtonClick = commandFactory.Create(OnRunTestButtonClick); SelectedEncryptionAlg = EncryptionAlgorithms.Aes256CbcHmacSha512; SelectedKdf = KeyTransformations.Pbkdf2; }
public MainViewModel( IUserService userService, IViewModelFactory factory, ICommandFactory commandFactory, IMessenger messenger, IWindowStorage <ViewModelBase> windowStorage) { this.userService = userService; this.factory = factory; this.messenger = messenger; this.windowStorage = windowStorage; CloseCommand = commandFactory.Create(OnClose); QuitCommand = commandFactory.Create(OnQuit); OpenCommand = commandFactory.Create(OnOpen); StateChangedCommand = commandFactory.Create(OnStateChanged); MenuButtonClick = commandFactory.Create(OnHideMenu); SettingsButtonClick = commandFactory.Create(OnSettingsClick); KeyChangeButtonClick = commandFactory.Create(OnKeyChangeClick); LogOutButtonClick = commandFactory.Create(OnLogOut); OnChangeView(new SwitchViewMessage { NextView = typeof(AuthenticationViewModel) }); }
public T Get(long id) { using (var cmd = _commandFactory.Create(SqlGenerator.GetSelectByIdQuery(), new { id })) { return(Mapper.GetObject <T>(cmd)); } }
public UserSettingsViewModel( IUserService userService, ICommandFactory commandFactory, IMessenger messenger, IStartupService startupService) { this.userService = userService; this.messenger = messenger; this.startupService = startupService; SaveButtonClick = commandFactory.Create(OnSaveButtonClick); BackButtonClick = commandFactory.Create(OnBackButtonClick); Settings = new Settings(User.Settings); }
public IObservable <Unit> Run() { IUnit unit = _unitRegistry.GetUnit(_data.unitId); if (unit == null) { _logger.LogError(LoggedFeature.Units, "MoveUnitSectionCommand called on unit not in registry: {0}", _data.unitId); return(Observable.Empty <Unit>()); } uint?unitIndex = _unitDataIndexResolver.ResolveUnitIndex(unit.UnitData); if (unitIndex == null) { _logger.LogError(LoggedFeature.Units, "Failed to resolve unit index: {0}", _data.unitId); return(Observable.Empty <Unit>()); } _despawnCommand = _commandFactory.Create <DespawnUnitCommand, DespawnUnitData>(new DespawnUnitData(_data.unitId)); _despawnCommand.Run(); var sectionLoadedSubject = new Subject <Unit>(); var commandData = new LoadMapSectionCommandData(_data.toSectionIndex, new LoadMapCommandData(_mapStoreId.index)); ICommand loadMapSectionCommand = _commandFactory.Create <LoadMapSectionCommand, LoadMapSectionCommandData>(commandData); loadMapSectionCommand.Run().Subscribe(_ => { // We need to wait 1 frame in order to avoid race conditions between listeners on new section Observable.IntervalFrame(1).First().Subscribe(__ => { IntVector2 entryTileCoords = _entryTileFinder.GetEntryTile(_data.toSectionIndex, _data.fromSectionIndex); // We don't spawn pets (which also are not despawn on despawn command) var unitCommandData = new UnitCommandData(unit.UnitId, unitIndex.Value, unit.UnitData.UnitType); var spawnUnitData = new SpawnUnitData(unitCommandData, entryTileCoords, isInitialSpawn: false); _spawnCommand = _commandFactory.Create <SpawnUnitCommand, SpawnUnitData>(spawnUnitData); _spawnCommand.Run(); sectionLoadedSubject.OnNext(Unit.Default); }); }); return(sectionLoadedSubject); }
public void AddEmployee_ShouldCreateAddEmployeeCommand() { var employeeController = GetEmployeeController(); A.CallTo(() => fakeCommandFactory.Create <AddEmployeeCommand>()).Returns(new AddEmployeeCommand(A.Fake <IDapperHub>(), A.Fake <ICommandFactory>()) { Execute = (employee, dependents) => {} }); employeeController.AddEmployee(new AddEmployeeParameters { NewEmployee = new Employee(), Dependents = new List <Dependents>() }); A.CallTo(() => fakeCommandFactory.Create <AddEmployeeCommand>()).MustHaveHappened(Repeated.Exactly.Once); }
public void Execute_ShouldCallDapperBeginGetAllAndCommit() { var employeeCommand = GetAddEmployeeCommand(); A.CallTo(() => fakeCommandFactory.Create <AddDependentsCommand>()).Returns(new AddDependentsCommand(A.Fake <IDapperHub>()) { Execute = employee => { } }); employeeCommand.Execute(A <Employee> ._, A <IEnumerable <Dependents> > ._); A.CallTo(() => fakeDapperHub.BeginTransaction()).MustHaveHappened(Repeated.Exactly.Once); A.CallTo(() => fakeDapperHub.Insert(A <Employee> ._)).MustHaveHappened(Repeated.Exactly.Once); A.CallTo(() => fakeDapperHub.CommitTransaction()).MustHaveHappened(Repeated.Exactly.Once); }
private void OnDragDrop(object sender, DragEventArgs dragEventArgs, ICommandFactory commandFactory) { //point they are dragged over var editor = ((Scintilla)sender); if (editor.ReadOnly) { return; } var clientPoint = editor.PointToClient(new Point(dragEventArgs.X, dragEventArgs.Y)); //get where the mouse is hovering over int pos = editor.CharPositionFromPoint(clientPoint.X, clientPoint.Y); var command = commandFactory.Create(dragEventArgs); if (command == null) { return; } //if it has a Form give it focus var form = editor.FindForm(); if (form != null) { form.Activate(); editor.Focus(); } editor.InsertText(pos, command.GetSqlString()); }
public IDbCommand GetNewCommand(CommandType commandType = CommandType.Text) { var cmd = _commandFactory.Create(); cmd.CommandType = commandType; return(cmd); }
private ICommand CreateTestRunnerCommand() { var commandArgs = _argumentsBuilder.BuildArguments(); return(_commandFactory.Create( $"dotnet-{_testRunner}", commandArgs)); }
public void Dispatch <TCommand>(TCommand command) { if (command == null) { throw new ArgumentNullException(nameof(command), "Command can not be null."); } var commandFactory = _factory.Create <TCommand>(); if (commandFactory == null) { throw new InvalidOperationException($"Handler {nameof(commandFactory)} can not be null"); } commandFactory.Handle(command); }
private void OnDragEnter(object sender, DragEventArgs dragEventArgs, ICommandFactory commandFactory) { var command = commandFactory.Create(dragEventArgs); if (command != null) { dragEventArgs.Effect = DragDropEffects.Copy; } }
public static void Main(string[] argv) { // this is the only line that is really dependent of a specific // implementation. _commandFactory = new TheSpecificImplementationAssembly.CommandFactory(); ICommand command = _commandFactory.Create("CreateUser"); command.Execute(); }
public int RunTests(DotnetTestParams dotnetTestParams) { return(_commandFactory.Create( _testRunnerNameResolver.ResolveTestRunner(), GetCommandArgs(dotnetTestParams), _framework, dotnetTestParams.Config) .Execute() .ExitCode); }
public async Task RunAsync() { var inputCommand = _commandFactory.Create("input"); Console.WriteLine("[+] " + inputCommand.Name); var task = inputCommand.RunAsync(_commandFactory.CancellationTokenSource.Token); _tasks.Add(task); _commands.Add(inputCommand); _taskCommands.Add(task, inputCommand); while (_tasks.Count > 0) { task = await Task.WhenAny(_tasks); try { string result = await task; inputCommand = _taskCommands[task]; Console.WriteLine("[-] " + inputCommand.Name); if (!string.IsNullOrEmpty(result)) { Console.WriteLine("[=] " + result); } var commands = inputCommand.Continuations(result, _commandFactory); foreach (var command in commands) { Console.WriteLine("[+] " + command.Name); Task <string> runTask = command.RunAsync(_commandFactory.CancellationTokenSource.Token); _tasks.Add(runTask); _commands.Add(command); _taskCommands.Add(runTask, command); } _tasks.Remove(task); _commands.Remove(_taskCommands[task]); _taskCommands.Remove(task); } catch (TaskCanceledException) { var command = _taskCommands[task]; Console.WriteLine("[-] " + inputCommand.Name); Console.WriteLine("[X] " + inputCommand.Name); if (_commands.Contains(command)) { _commands.Remove(command); } _tasks.Remove(task); _taskCommands.Remove(task); } } }
public ProcessResponse Process(ProcessRequest request) { var response = new ProcessResponse(); foreach (var command in _commandFactory.Create(request.CommandType)) { response.Messages.Add(command.Process(request)); } return(response); }
private object ConstructCommand(IOwinContext context) { var commandType = GetCommandType(context); var command = commandFactory.Create(commandType, context.Environment); if (command == null) { throw new EmptyCommandBodyException(commandType); } return(command); }
public void Creates_listcommands_command_when_null_arguments_passed(ICommandFactory commandFactory, ICraneCommand craneCommand) { "Given I have a command factory" ._(() => commandFactory = ServiceLocator.Resolve <ICommandFactory>()); "When I create a command with no arguments" ._(() => craneCommand = commandFactory.Create(null)); "Then the command returned should be the list commands command" ._(() => craneCommand.Should().BeOfType <ListCommands>()); }
private void Execute(List <string> args) { string commandName = string.Empty; if (args.Count >= 1 && Regex.IsMatch(args[0], "^[a-z]+$")) { commandName = args[0]; args.RemoveAt(0); // Remove the argument we just used } // Attempt to find the command for the name CommandDescriptor commandDescriptor = commandRegistry.GetDescriptor(commandName, null); if (commandDescriptor == null) { throw new Exception(string.Format("Command '{0}' is not recognized.", commandName)); } // Determine if this is a call for a sub command while (args.Count >= 1 && Regex.IsMatch(args[0], "^[a-z]+$")) { commandName = args[0]; var subCommandDescriptor = commandRegistry.GetDescriptor(commandName, commandDescriptor); if (subCommandDescriptor == null) { break; } commandDescriptor = subCommandDescriptor; args.RemoveAt(0); // Remove the argument we just used } // Create an instance of the required command ICommand command = commandFactory.Create(commandDescriptor.CommandType); // Parse the arguments and apply them to the command if (args.Count > 0) { foreach (IArgumentParser argumentParser in argumentParsers) { argumentParser.Apply(args, command, commandDescriptor); } // Ensure that all the arguments have been parsed if (args.Count > 0) { throw new Exception(string.Format("Unsupported argument '{0}'.", args[0])); } } // Execute the code of the command command.Execute(); }