Exemple #1
0
        public MonstersService(MonsterContext monsterContext, IOptions <AppSettings> appSettingsAccessor)
        {
            _monsterContext = monsterContext;
            _chanceSettings = appSettingsAccessor.Value.MonsterTypeChances;

            _random = new Random();
        }
        public MonsterRepository(string connectionString, string schemaName)
        {
            if (_monsterContext != null)
            {
                return;
            }

            _monsterContext = new MonsterContext(connectionString, schemaName);
        }
Exemple #3
0
        public MonsterRepository()
        {
            if (_monsterContext != null)
            {
                return;
            }

            _monsterContext = new MonsterContext(Settings.GetConnectionString("Database"));
        }
 protected override async Task CreateAndSeedDatabase(IServiceProvider serviceProvider, string databaseName)
 {
     using (var context = new MonsterContext(serviceProvider, CreateOptions(databaseName)))
     {
         context.Database.EnsureDeleted();
         context.Database.EnsureCreated();
         context.SeedUsingFKs();
     }
 }
Exemple #5
0
        public static void StateDemo()
        {
            MonsterContext Context     = new MonsterContext();
            IMonsterState  SleepState  = new SleepState();
            IMonsterState  AttackState = new AttackState();
            IMonsterState  SpeakState  = new SpeakState();

            Context.SetState(AttackState);
            Context.Action();
            Context.SetState(SleepState);
            Context.Action();
            Context.SetState(SpeakState);
            Context.Action();
        }
Exemple #6
0
        public SimpleIntegrationTest()
        {
            var serviceProvider = new ServiceCollection()
                                  .AddEntityFrameworkSqlServer()
                                  .BuildServiceProvider();

            var builder = new DbContextOptionsBuilder <MonsterContext>();

            builder.UseSqlServer($"Server=(localdb)\\mssqllocaldb;Database=monsters_db_{Guid.NewGuid()};Trusted_Connection=True;MultipleActiveResultSets=true")
            .UseInternalServiceProvider(serviceProvider);

            _context = new MonsterContext(builder.Options);
            _context.Database.Migrate();
        }
        protected override async Task CreateAndSeedDatabase(IServiceProvider serviceProvider, string databaseName)
        {
            using (await _creationLock.LockAsync())
            {
                if (!_databaseCreated)
                {
                    using (var context = new MonsterContext(serviceProvider, CreateOptions(databaseName)))
                    {
                        context.Database.EnsureDeleted();
                        context.Database.EnsureCreated();
                        context.SeedUsingFKs();
                    }

                    _databaseCreated = true;
                }
            }
        }
 public DbMonster Get(int monsterId)
 {
     using (var context = Services.GetService <GuildManagerContext>())
     {
         try
         {
             var monsterContext = new MonsterContext(context);
             var monster        = monsterContext.GetMonsterById(monsterId);
             return(monster);
         }
         catch (Exception e)
         {
             Console.WriteLine(e);
             throw;
         }
     }
 }
Exemple #9
0
        public ActionResult Create()
        {
            Models.Dungeon dungeon = new Models.Dungeon();
            dungeon.SetDungeonSize(Request.Form["dungeonSize"].ToString());
            dungeon.SetCorridorSize(Request.Form["corridorLong"].ToString());
            dungeon.SetRoomSize(Request.Form["roomSize"].ToString());
            dungeon.SetChanceOfRoom(Request.Form["roomDensity"].ToString());
            dungeon.CreateName();
            dungeon.CreateDungeon();
            dungeon.CreateDungeonTraits();
            List <Monster> monsters = new List <Monster>();

            using (MonsterContext db = new MonsterContext())
            {
                monsters = new List <Monster>(db.Monsters.ToList());
                foreach (Monster monster in monsters)
                {
                    monster.MonsterAbilities = db.Abilities.FirstOrDefault(a => a.ID == monster.MonsterID);
                }
            };
            dungeon.CreateErrantMonsters(monsters);
            return(View("Details", dungeon));
        }
 // here we can "inject" our context service into the constructor
 public LogRegController(MonsterContext context)
 {
     dbContext = context;
 }
 public HomeController(MonsterContext context)
 {
     dbContext = context;
 }
 void Awake()
 {
     MonsterContext = new MonsterContext();
     _Animator      = GetComponent <Animator>();
 }
Exemple #13
0
 public CustomerRepository(MonsterContext dbContext)
 {
     _context   = dbContext;
     _customers = dbContext.Customers;
 }
 public ImageRepository(MonsterContext dbContext)
 {
     _context = dbContext;
     _images  = dbContext.Images;
 }
Exemple #15
0
 public MonsterRepository(MonsterContext dbContext)
 {
     _context = dbContext;
     _monster = dbContext.Monster;
 }
 public ScaryMonstersQuery(MonsterContext context)
 {
     _context = context;
 }