Пример #1
0
 public CodeController(IUserRepository repository,
     GameServerContext context, SecurityHelper helper)
 {
     this.repository = repository;
     this.context = context;
     this.helper = helper;
 }
Пример #2
0
        public static void RegisterTypes(IUnityContainer container)
        {
            GameServerContext gameServerContext = new GameServerContext();

            container.RegisterInstance(
                (IUserRepository)new MemoryUserRepository(gameServerContext));
            container.RegisterInstance(gameServerContext);
            container.RegisterType<SecurityHelper, SecurityHelper>();
        }
Пример #3
0
        public MemoryUserRepository(GameServerContext context)
        {
            /*DBUser u = new DBUser();
            u.Username = "******";
            u.ShipPresetId = 1;
            u.Code = "";
            u.CellTypes = new int[] { 0, 2, 1, 3, 1, 2 };
            u.PasswordHash = "123";
            context.Users.Add(u);
            context.SaveChanges();*/

            UpdateFromDB(context);
        }
Пример #4
0
        /// <summary>
        /// Loading all users from database to Users list
        /// </summary>
        /// <param name="context"></param>
        public void UpdateFromDB(GameServerContext context)
        {
            _users = new List<User>();
            foreach (DBUser dbUser in context.Users)
            {
                addUserFromDB(dbUser);
            }

            if(_users.Count >= 2)
            {
                _users[0].enemyShip = _users[1].ship;
                _users[1].enemyShip = _users[0].ship;
            }
        }