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

            _random = new Random();
        }
コード例 #2
0
        public MonsterRepository(string connectionString, string schemaName)
        {
            if (_monsterContext != null)
            {
                return;
            }

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

            _monsterContext = new MonsterContext(Settings.GetConnectionString("Database"));
        }
コード例 #4
0
 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();
     }
 }
コード例 #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();
        }
コード例 #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();
        }
コード例 #7
0
        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;
                }
            }
        }
コード例 #8
0
 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;
         }
     }
 }
コード例 #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));
        }
コード例 #10
0
 // here we can "inject" our context service into the constructor
 public LogRegController(MonsterContext context)
 {
     dbContext = context;
 }
コード例 #11
0
 public HomeController(MonsterContext context)
 {
     dbContext = context;
 }
コード例 #12
0
 void Awake()
 {
     MonsterContext = new MonsterContext();
     _Animator      = GetComponent <Animator>();
 }
コード例 #13
0
 public CustomerRepository(MonsterContext dbContext)
 {
     _context   = dbContext;
     _customers = dbContext.Customers;
 }
コード例 #14
0
 public ImageRepository(MonsterContext dbContext)
 {
     _context = dbContext;
     _images  = dbContext.Images;
 }
コード例 #15
0
 public MonsterRepository(MonsterContext dbContext)
 {
     _context = dbContext;
     _monster = dbContext.Monster;
 }
 public ScaryMonstersQuery(MonsterContext context)
 {
     _context = context;
 }