2018-01-05 19:21:19 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-10-17 15:02:13 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2017-10-17 14:00:27 +08:00
|
|
|
|
|
|
|
|
|
using osu.Framework.Platform;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Database
|
|
|
|
|
{
|
|
|
|
|
public class DatabaseContextFactory
|
|
|
|
|
{
|
|
|
|
|
private readonly GameHost host;
|
|
|
|
|
|
2017-10-20 23:15:02 +08:00
|
|
|
|
private const string database_name = @"client";
|
|
|
|
|
|
2017-10-17 14:00:27 +08:00
|
|
|
|
public DatabaseContextFactory(GameHost host)
|
|
|
|
|
{
|
|
|
|
|
this.host = host;
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-20 23:15:02 +08:00
|
|
|
|
public OsuDbContext GetContext() => new OsuDbContext(host.Storage.GetDatabaseConnectionString(database_name));
|
|
|
|
|
|
|
|
|
|
public void ResetDatabase()
|
|
|
|
|
{
|
|
|
|
|
// todo: we probably want to make sure there are no active contexts before performing this operation.
|
|
|
|
|
host.Storage.DeleteDatabase(database_name);
|
|
|
|
|
}
|
2017-10-17 14:00:27 +08:00
|
|
|
|
}
|
|
|
|
|
}
|