/// <summary> /// Delegate called when a command is done. /// </summary> /// <param name="pSource">The source command.</param> /// <param name="pEventArgs">The event arguments.</param> protected virtual void CustomOnCommandDone(IUserCommand pSource, CommandExecutionEventArgs pEventArgs) { // Verifying if the context must be changed. if (pEventArgs.Command.State == UserCommandState.SwitchContext) { ISwitchContextCommand lCommand = pEventArgs.Command as ISwitchContextCommand; if (lCommand != null) { string lNewContextId = lCommand.SwitchContext(this.Id); this.mParentManager.SwitchContext(lNewContextId); } } // Evaluating if the new command must be added in the context list. bool lAddCommand = true; if (this.CommandsList.Any() && this.LastExecutedCommand != null && pEventArgs.Command.State == UserCommandState.Undoable) { lAddCommand = this.LastExecutedCommand.TryMerge(pEventArgs.Command) == false; } if (pEventArgs.Command.State != UserCommandState.Undoable) { lAddCommand = false; } // Adding the command in the list if wanted. if (lAddCommand) { this.CommandsList.Add(pEventArgs.Command); this.CurrentCommandIndex = this.CommandsList.Count - 1; } }
/// <summary> /// Registers and execute the given command. /// </summary> /// <param name="pCommand">The command to execute.</param> public virtual void Do(IUserCommand pCommand) { // Command validation. if (pCommand == null) { return; } // Removing the undone commands. this.RemoveUndoneCommand(); // Do the command. pCommand.Do(); // Evaluating if the new command must be added in the context list. bool lAddCommand = true; if (this.CommandsList.Any() && this.LastExecutedCommand != null && pCommand.State != UserCommandState.Internal) { lAddCommand = this.LastExecutedCommand.TryMerge(pCommand) == false; } if (pCommand.State == UserCommandState.Internal) { lAddCommand = false; } // Adding the command in the list if wanted. if (lAddCommand) { this.CommandsList.Add(pCommand); this.CurrentCommandIndex = this.CommandsList.Count - 1; } }
/// <summary> /// Delegate called when a command is undone. /// </summary> /// <param name="pSource">The source command.</param> /// <param name="pEventArgs">The event arguments.</param> protected virtual void CustomOnCommandUndone(IUserCommand pSource, CommandExecutionEventArgs pEventArgs) { // Updating the current command index. int lCommandIndex = this.CommandsList.IndexOf(pEventArgs.Command); this.CurrentCommandIndex = --lCommandIndex; }
public UsersController(IUserQuery userQuery, IUserCommand userCommand, IUrlHelper urlHelper, ILogger <UsersController> logger) { _userQuery = userQuery; _userCommand = userCommand; _urlHelper = urlHelper; _logger = logger; }
/// <summary> /// Registers and execute the given command. /// </summary> /// <param name="pCommand">The command to execute.</param> public void Do(IUserCommand pCommand) { if (this.CurrentContext != null) { this.CurrentContext.Do(pCommand); } }
/// <summary> /// Registers and execute the given command. /// </summary> /// <param name="pCommand">The command to execute.</param> public override void Do(IUserCommand pCommand) { // Command validation. if (pCommand == null) { return; } // Do the command. pCommand.Do(); // Evaluating if the new command must be added in the context list. bool lAddCommand = true; if (this.CommandsList.Any() && this.LastExecutedCommand != null) { lAddCommand = this.LastExecutedCommand.TryMerge(pCommand) == false; } // Adding the command in the list if wanted. if (lAddCommand) { this.CommandsList.Add(pCommand); this.CurrentCommandIndex = this.CommandsList.Count - 1; } }
public void Update(int currentFrame, IUserCommand command) { MenuFrameCounter += 1; if (IsMenuLocked) { return; } if (command?.CommandType == UserCommandType.DiscardBullet) { var discardCommand = command as DiscardBulletCommand; var replacementBullet = discardCommand.ReplacementBullet; DiscardBullet(replacementBullet); return; } if (MenuFrameCounter % AutoDiscardTime == 0) { var replacementBullet = RandomBullet(); DiscardBullet(replacementBullet); return; } }
public UsersController(IMapper mapper, ILoggerManager logger, IUserQuery userQuery, IUserCommand userCommand) : base(mapper, logger) { _userQuery = userQuery; _userCommand = userCommand; }
/// <summary> /// Registers and execute the given command. /// </summary> /// <param name="pCommand">The command to execute.</param> protected virtual void CustomDo(IUserCommand pCommand) { // Removing the undone commands. this.RemoveUndoneCommand(); // Do the command. pCommand.Do(); }
public void AddMouseDown(MouseEventArgs evt) { IUserCommand lastCommand = GetLastCommand(); var mouseDown = new MouseDownCommand(evt); Commands.Add(mouseDown); Dbg <MouseDownCommand>("Added", evt); }
public UserController(IHttpContextAccessor httpContextAccessor, IUserCommand userCommand, ILogger <UserController> logger, UserManager <UserModel> userManager, IListingCommand listingCommand) { _listingCommand = listingCommand; _userManager = userManager; _logger = logger; _userCommand = userCommand; _httpContextAccessor = httpContextAccessor; }
public void Update(int currentFrame, IUserCommand command) { // Move Game Objects foreach (var lane in Lanes) { if (currentFrame % MonsterSpeedTime == 0) { lane.MoveMonsters(); } if (currentFrame % BulletSpeedTime == 0) { lane.MoveBullets(); } } // Update BulletBar Menu.Update( currentFrame: currentFrame, command: command); // Spawn Enemies, Bullets, Etc. // Spawn Monster if (currentFrame % MonsterSpawnTime == 0) { var randomLane = Util.RandomElement(Lanes, Game.RandomGenerator); var randomMonster = RandomMonster(); randomLane.SpawnMonster(randomMonster); } // Shoot Bullet if (command?.CommandType == UserCommandType.Shoot) { var shootCommand = (command as ShootCommand); if (shootCommand != null) { var bullet = shootCommand.Bullet; var laneIndex = shootCommand.LaneIndex; var lane = Lanes[laneIndex]; lane.ShootBullet(bullet); } } // Collision Check foreach (var lane in Lanes) { lane.CollisionCheck(); } }
}// END Map(IMergePatch... //////////////////////////// protected virtual IUserLoginStateRemoved MapRemove(IRemoveUserLogin c, IUserCommand outerCommand, long version) { c.RequesterId = outerCommand.RequesterId; var stateEventId = new UserLoginStateEventId(c.UserId, c.LoginKey, version); IUserLoginStateRemoved e = NewUserLoginStateRemoved(stateEventId); e.CreatedBy = (string)c.RequesterId; e.CreatedAt = DateTime.Now; return(e); }// END Map(IRemove... ////////////////////////////
}// END Map(IMergePatch... //////////////////////////// protected virtual IUserLoginStateRemoved MapRemove(IRemoveUserLogin c, IUserCommand outerCommand, long version) { c.RequesterId = outerCommand.RequesterId; var stateEventId = new UserLoginEventId(c.UserId, c.LoginKey, version); IUserLoginStateRemoved e = NewUserLoginStateRemoved(stateEventId); e.CreatedBy = (string)c.RequesterId; e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>(); return(e); }// END Map(IRemove... ////////////////////////////
protected virtual IUserLoginStateCreated MapCreate(ICreateUserLogin c, IUserCommand outerCommand, long version, IUserState outerState) { c.RequesterId = outerCommand.RequesterId; var stateEventId = new UserLoginEventId(c.UserId, c.LoginKey, version); IUserLoginStateCreated e = NewUserLoginStateCreated(stateEventId); var s = outerState.UserLogins.Get(c.LoginKey, true); e.Active = c.Active; e.CreatedBy = (string)c.RequesterId; e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>(); return(e); }// END Map(ICreate... ////////////////////////////
protected virtual IUserLoginStateCreated MapCreate(ICreateUserLogin c, IUserCommand outerCommand, long version, IUserState outerState) { c.RequesterId = outerCommand.RequesterId; var stateEventId = new UserLoginStateEventId(c.UserId, c.LoginKey, version); IUserLoginStateCreated e = NewUserLoginStateCreated(stateEventId); var s = outerState.UserLogins.Get(c.LoginKey); e.Active = c.Active; e.CreatedBy = (string)c.RequesterId; e.CreatedAt = DateTime.Now; return(e); }// END Map(ICreate... ////////////////////////////
/// <summary> /// Delegate called when a command is undoing. /// </summary> /// <param name="pSource">The source command.</param> /// <param name="pEventArgs">The event arguments.</param> private void OnCommandUndoing(IUserCommand pSource, CommandExecutionEventArgs pEventArgs) { // Custom process. this.CustomOnCommandUndoing(pSource, pEventArgs); // Internal notification. if (this.CommandUndoing != null) { this.CommandUndoing(this, pEventArgs); } // Manager notification. this.mParentManager.NotifyCommandExecution(UserCommandManager.CommandExecutionType.Undoing, pEventArgs); }
protected bool IsRepeatedCommand(IUserCommand command, IEventStoreAggregateId eventStoreAggregateId, IUserState state) { bool repeated = false; if (((IUserStateProperties)state).Version > command.AggregateVersion) { var lastEvent = EventStore.FindLastEvent(typeof(IUserStateEvent), eventStoreAggregateId, command.AggregateVersion); if (lastEvent != null && lastEvent.CommandId == command.CommandId) { repeated = true; } } return(repeated); }
protected virtual IUserClaimStateCreated MapCreate(ICreateUserClaim c, IUserCommand outerCommand, long version, IUserState outerState) { c.RequesterId = outerCommand.RequesterId; var stateEventId = new UserClaimStateEventId(c.UserId, c.ClaimId, version); IUserClaimStateCreated e = NewUserClaimStateCreated(stateEventId); var s = outerState.UserClaims.Get(c.ClaimId, true); e.ClaimType = c.ClaimType; e.ClaimValue = c.ClaimValue; e.Active = c.Active; e.CreatedBy = (string)c.RequesterId; e.CreatedAt = DateTime.Now; return(e); }// END Map(ICreate... ////////////////////////////
}// END ThrowOnInconsistentCommands ///////////////////// protected void ThrowOnInconsistentCommands(IUserCommand command, IUserLoginCommand innerCommand) { var properties = command as ICreateOrMergePatchOrDeleteUser; var innerProperties = innerCommand as ICreateOrMergePatchOrRemoveUserLogin; if (properties == null || innerProperties == null) { return; } var outerUserIdName = "UserId"; var outerUserIdValue = properties.UserId; var innerUserIdName = "UserId"; var innerUserIdValue = innerProperties.UserId; SetNullInnerIdOrThrowOnInconsistentIds(innerProperties, innerUserIdName, innerUserIdValue, outerUserIdName, outerUserIdValue); }// END ThrowOnInconsistentCommands /////////////////////
/// <summary> /// Registers and execute the given command. /// </summary> /// <param name="pCommand">The command to execute.</param> public void Do(IUserCommand pCommand) { // Command validation. if (pCommand == null) { return; } if (this.mSessions.Any() == false) { // Ensuring at least one session exists. this.mSessions.Add(this.CreateSession()); } // Executing the command. }
public GroupMembershipService(ILogger <GroupMembershipService> logger, ISystemClock systemClock, IGroupCommand groupCommand, IRolesCommand rolesCommand, IUserCommand userCommand, IPermissionsService permissionsService, IGroupMemberNotificationService groupMemberNotificationService) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _systemClock = systemClock ?? throw new ArgumentNullException(nameof(systemClock)); _groupCommand = groupCommand ?? throw new ArgumentNullException(nameof(groupCommand)); _rolesCommand = rolesCommand ?? throw new ArgumentNullException(nameof(rolesCommand)); _userCommand = userCommand ?? throw new ArgumentNullException(nameof(userCommand)); _permissionsService = permissionsService ?? throw new ArgumentNullException(nameof(permissionsService)); _groupMemberNotificationService = groupMemberNotificationService ?? throw new ArgumentNullException(nameof(groupMemberNotificationService)); }
/// <summary> /// Delegate called when a command is done. /// </summary> /// <param name="pSource">The source command.</param> /// <param name="pEventArgs">The event arguments.</param> protected override void CustomOnCommandDone(IUserCommand pSource, CommandExecutionEventArgs pEventArgs) { // Evaluating if the new command must be added in the context list. bool lAddCommand = true; if (this.CommandsList.Any() && this.LastExecutedCommand != null) { lAddCommand = this.LastExecutedCommand.TryMerge(pEventArgs.Command) == false; } // Adding the command in the list if wanted. if (lAddCommand) { this.CommandsList.Add(pEventArgs.Command); this.CurrentCommandIndex = this.CommandsList.Count - 1; } }
protected virtual void Update(IUserCommand c, Action <IUserAggregate> action) { var aggregateId = c.AggregateId; var state = StateRepository.Get(aggregateId, false); var aggregate = GetUserAggregate(state); var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId); var repeated = IsRepeatedCommand(c, eventStoreAggregateId, state); if (repeated) { return; } aggregate.ThrowOnInvalidStateTransition(c); action(aggregate); Persist(eventStoreAggregateId, aggregate, state); }
/// <summary> /// Registers and execute the given command. /// </summary> /// <param name="pCommand">The command to execute.</param> public void Do(IUserCommand pCommand) { if (pCommand == null) { return; } if (this.mSessions.Any() == false || pCommand.State == UserCommandState.NewSession) { // Ensuring at least one session exists. New session is created on demande as well. this.mSessions.Add(this.CreateSession()); } // Executing the command. if (this.mSessions.CurrentSession != null) { this.mSessions.CurrentSession.Do(pCommand); } }
protected virtual void Update(IUserCommand c, Action <IUserAggregate> action) { var aggregateId = c.AggregateId; var state = StateRepository.Get(aggregateId, false); var aggregate = GetUserAggregate(state); var eventStoreAggregateId = ToEventStoreAggregateId(aggregateId); var repeated = IsRepeatedCommand(c, eventStoreAggregateId, state); if (repeated) { return; } aggregate.ThrowOnInvalidStateTransition(c); action(aggregate); EventStore.AppendEvents(eventStoreAggregateId, ((IUserStateProperties)state).Version, aggregate.Changes, () => { StateRepository.Save(state); }); }
/// <summary> /// Redo the current command of the context. /// </summary> public void Redo() { if (this.CanRedo) { // Locking the execution of an other command. this.mIsExecutingCommand = true; // Getting the command to redo. IUserCommand lCommand = this.CommandsList[this.CurrentCommandIndex + 1]; // Registering on command events. lCommand.Doing += this.OnCommandDoing; lCommand.Done += this.OnCommandRedone; lCommand.Failed += this.OnCommandFailed; // Do the command. this.CustomRedo(lCommand); } }
public AdminUserService(ILogger <AdminUserService> logger, ISystemClock systemClock, IPermissionsService permissionsService, IUserAdminDataProvider userAdminDataProvider, IRolesDataProvider rolesDataProvider, IUserCommand userCommand, IEmailService emailService, IOptionsSnapshot <GovNotifyConfiguration> notifyConfig, IOptionsSnapshot <ApplicationGateway> gatewayConfig) { _permissionsService = permissionsService; _userAdminDataProvider = userAdminDataProvider; _rolesDataProvider = rolesDataProvider; _systemClock = systemClock; _logger = logger; _userCommand = userCommand; _emailService = emailService; _fqdn = gatewayConfig.Value.FQDN; // Notification template Ids _registrationEmailId = notifyConfig.Value.RegistrationEmailTemplateId; }
}// END ThrowOnInconsistentCommands ///////////////////// protected void ThrowOnInconsistentCommands(IUserCommand command, IUserPermissionCommand innerCommand) { var properties = command as ICreateOrMergePatchOrDeleteUser; var innerProperties = innerCommand as ICreateOrMergePatchOrRemoveUserPermission; if (properties == null || innerProperties == null) { return; } if (innerProperties.UserId == default(string)) { innerProperties.UserId = properties.UserId; } else { var outerUserIdName = "UserId"; var outerUserIdValue = properties.UserId; var innerUserIdName = "UserId"; var innerUserIdValue = innerProperties.UserId; ThrowOnInconsistentIds(innerProperties, innerUserIdName, innerUserIdValue, outerUserIdName, outerUserIdValue); } }// END ThrowOnInconsistentCommands /////////////////////
/// <summary> /// Delegate called when a command is redone. /// </summary> /// <param name="pSource">The source command.</param> /// <param name="pEventArgs">The event arguments.</param> private void OnCommandRedone(IUserCommand pSource, CommandExecutionEventArgs pEventArgs) { // Unregistering form events. pEventArgs.Command.Doing -= this.OnCommandDoing; pEventArgs.Command.Done -= this.OnCommandRedone; pEventArgs.Command.Failed -= this.OnCommandFailed; // Custom process. this.CustomOnCommandRedone(pSource, pEventArgs); // Unlocking the command execution. this.mIsExecutingCommand = false; // Internal notification. if (this.CommandDone != null) { this.CommandDone(this, pEventArgs); } // Manager notification. this.mParentManager.NotifyCommandExecution(UserCommandManager.CommandExecutionType.Done, pEventArgs); }
public UserService(IUserCommand userCommand, IUserQuery userQuery) { _userCommand = userCommand; _userQuery = userQuery; }