public UserSignUpDtoOutput CreateUser(string token, UserSignUpDtoInput userDto) { User newUser; if (token != null) { VerifyCredentialsForUserCreation(token); newUser = GlobalFactory.User(userDto.Role) as User; } else { newUser = GlobalFactory.User(typeof(User).Name) as User; } _objectMapper.Map(userDto, newUser); if (!newUser.IsValid()) { throw new ModelValidationException(_objectMapper.Map <List <ValidationErrorDto> >(newUser.GetValidationErrors())); } _userRepository.Insert(newUser); SaveChanges(); return(_objectMapper.Map <UserSignUpDtoOutput>(newUser)); }
private Global() { var gf = new GlobalFactory(); Config = gf.GetConfig(); Registry = gf.GetRegistry(); }
protected override void Load(ContainerBuilder builder) { var gf = new GlobalFactory(); var rc = gf.GetGlobal(); builder.RegisterInstance(rc.Item1).SingleInstance().AsSelf(); builder.RegisterInstance(rc.Item2).SingleInstance().AsSelf(); }
static PowerUpFactory() { //init all pools and add them to the dictionary GlobalFactory <SpeedPow> .RegisterPool(typeof(SpeedPow), () => new SpeedPow()); GlobalFactory <BombPow> .RegisterPool(typeof(BombPow), () => new BombPow()); GlobalFactory <WallPass> .RegisterPool(typeof(WallPass), () => new WallPass()); GlobalFactory <Mystery> .RegisterPool(typeof(Mystery), () => new Mystery()); }
private void RestartGame() { if (this.matrixAlgorithm != null) { this.matrixAlgorithm.GameEnd -= this.TicTacToeGameEnd; this.matrixAlgorithm = null; } this.aiMove = (IAiMove)GlobalFactory.Create(typeof(IAiMove)); this.SetupBoard(this.boardSizeTrackBar.Value); }
public Data ReadIni(String fileName) { if (String.IsNullOrWhiteSpace(fileName)) { throw new ArgumentOutOfRangeException(nameof(fileName), "file name may not be empty, null or whitespace"); } this.MatrixAlgorithm = (IMatrixAlgorithm)GlobalFactory.Create(typeof(IMatrixAlgorithm)); FileIniDataParser parser = new FileIniDataParser(); IniData iniData = parser.ReadFile(fileName); SavedGameState savedGameState = new SavedGameState { BoardSize = this.MatrixAlgorithm.BoardSize, CurrentTurn = this.MatrixAlgorithm.CurrentTurn, CurrentTurnCount = this.MatrixAlgorithm.CurrentTurnCount, }; Data data = new Data { CurrentGame = savedGameState, HistoryList = new List <History>() }; data.CurrentGame.CurrentTurnCount = Convert.ToInt32(iniData["CurrentGame"]["CurrentTurnCount"]); data.CurrentGame.BoardSize = Convert.ToInt32(iniData["CurrentGame"]["BoardSize"]); data.Round = Convert.ToInt32(iniData["Settings"]["Difficutly"]); data.Difficulty = (Difficulty)Enum.Parse(typeof(Difficulty), iniData["Settings"]["Difficulty"]); Int32 sectionIndex = 0; using (StreamReader sr = File.OpenText(fileName)) { foreach (SectionData section in iniData.Sections) { sectionIndex++; } } for (Int32 i = 0; i < sectionIndex - 2; i++) { History history = new History { Winner = iniData[$"HistoryList-{i}"]["Winner"], RoundCount = Convert.ToInt32(iniData[$"HistoryList-{i}"]["RoundCount"]) }; data.HistoryList.Add(history); } String key = $"Board"; String value = iniData["CurrentGame"][key]; data.CurrentGame.BoardData = value; return(data); }
public static IEnemy Get(EnemyType type) { IEnemy returnInstance = null; switch (type) { case EnemyType.Balloom: returnInstance = GlobalFactory <IEnemy> .Get(typeof(Balloom)); break; case EnemyType.Doll: returnInstance = GlobalFactory <IEnemy> .Get(typeof(Doll)); break; case EnemyType.Oneal: returnInstance = GlobalFactory <IEnemy> .Get(typeof(Oneal)); break; case EnemyType.Minvo: returnInstance = GlobalFactory <IEnemy> .Get(typeof(Minvo)); break; case EnemyType.Ovapi: returnInstance = GlobalFactory <IEnemy> .Get(typeof(Ovapi)); break; case EnemyType.Kondoria: returnInstance = GlobalFactory <IEnemy> .Get(typeof(Kondoria)); break; case EnemyType.Pass: returnInstance = GlobalFactory <IEnemy> .Get(typeof(Pass)); break; case EnemyType.Pontan: returnInstance = GlobalFactory <IEnemy> .Get(typeof(Pontan)); break; default: break; } return(returnInstance); }
public Entities.Media CreateMediaEntity(string filePath, string fileName, string mediaMappedPath) { _mediaMappedPath = mediaMappedPath; FilePathResolver.MediaType fileMediaType = FilePathResolver.GetFileType(fileName); string fileTypeName = FilePathResolver.GetFileTypeName(fileMediaType); _mediaManager = (MediaManager)GlobalFactory.MediaManager(fileTypeName); return(new Entities.Media { MediaType = fileMediaType, Path = filePath, OriginalName = fileName }); }
private void SetupBoard(Int32 dimension) { if (dimension < 2) { throw new ArgumentOutOfRangeException(nameof(dimension)); } this.matrixAlgorithm = (IMatrixAlgorithm)GlobalFactory.Create(typeof(IMatrixAlgorithm)); this.matrixAlgorithm.GameEnd += this.TicTacToeGameEnd; this.gamePanel.Difficulty = this.ChooseDifficulty(); this.mainTableLayloutPanel.Controls.Clear(); this.mainTableLayloutPanel.RowCount = dimension; this.mainTableLayloutPanel.ColumnCount = dimension; this.gamePanel.ButtonList = new List <Button>(); for (Int32 row = 0; row < dimension; row++) { for (Int32 col = 0; col < dimension; col++) { Button current = new Button { Height = 62, Width = 62, Tag = new PointIndex(col, row) }; this.gamePanel.ButtonList.Add(current); current.Click += this.PlayerButtonOnClick; this.mainTableLayloutPanel.Controls.Add(current, col, row); } } this.matrixAlgorithm.InitializeBoard(dimension); if (this.gamePanel.Difficulty == Difficulty.Middle) { this.ClickAiMiddle(); } this.ShowStats(); }
static EnemyFactory() { GlobalFactory <IEnemy> .RegisterPool(typeof(Balloom), () => new Balloom()); GlobalFactory <IEnemy> .RegisterPool(typeof(Doll), () => new Doll()); GlobalFactory <IEnemy> .RegisterPool(typeof(Oneal), () => new Oneal()); GlobalFactory <IEnemy> .RegisterPool(typeof(Minvo), () => new Minvo()); GlobalFactory <IEnemy> .RegisterPool(typeof(Ovapi), () => new Ovapi()); GlobalFactory <IEnemy> .RegisterPool(typeof(Pass), () => new Pass()); GlobalFactory <IEnemy> .RegisterPool(typeof(Kondoria), () => new Kondoria()); GlobalFactory <IEnemy> .RegisterPool(typeof(Pontan), () => new Pontan()); }
public static IPowerup Get(PowerUpType type) { IPowerup toReturn = null; switch (type) { case PowerUpType.PW_SPEED: toReturn = GlobalFactory <SpeedPow> .Get(typeof(SpeedPow)); break; case PowerUpType.PW_BOMB: toReturn = GlobalFactory <BombPow> .Get(typeof(BombPow)); break; case PowerUpType.PW_BOMB_PASS: break; case PowerUpType.PW_FLAME: break; case PowerUpType.PW_FLAME_PASS: break; case PowerUpType.PW_WALL_PASS: toReturn = GlobalFactory <WallPass> .Get(typeof(WallPass)); break; case PowerUpType.PW_MYSTERY: toReturn = GlobalFactory <Mystery> .Get(typeof(Mystery)); break; case PowerUpType.PW_DETONATOR: break; default: break; } return(toReturn); }