Refactor Database class (#616)

Refactor Database into DatabaseContext
Moved into separate folder so it actually has a namespace instead sitting in the root
This commit is contained in:
Josh 2023-02-15 23:54:30 -06:00 committed by GitHub
parent 2aff26f83d
commit 64b95e807d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
246 changed files with 1211 additions and 965 deletions

View file

@ -1,6 +1,7 @@
#nullable enable
using System.Diagnostics.CodeAnalysis;
using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Types;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
@ -17,9 +18,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
[Produces("text/plain")]
public class ClientConfigurationController : ControllerBase
{
private readonly Database database;
private readonly DatabaseContext database;
public ClientConfigurationController(Database database)
public ClientConfigurationController(DatabaseContext database)
{
this.database = database;
}

View file

@ -1,4 +1,5 @@
#nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Serialization;
@ -18,8 +19,8 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
[Produces("text/xml")]
public class CommentController : ControllerBase
{
private readonly Database database;
public CommentController(Database database)
private readonly DatabaseContext database;
public CommentController(DatabaseContext database)
{
this.database = database;
}

View file

@ -1,4 +1,5 @@
#nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Serialization;
@ -18,9 +19,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
[Route("LITTLEBIGPLANETPS3_XML/")]
public class FriendsController : ControllerBase
{
private readonly Database database;
private readonly DatabaseContext database;
public FriendsController(Database database)
public FriendsController(DatabaseContext database)
{
this.database = database;
}

View file

@ -1,6 +1,7 @@
#nullable enable
using System.Net;
using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging;
@ -19,9 +20,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
[Produces("text/xml")]
public class LoginController : ControllerBase
{
private readonly Database database;
private readonly DatabaseContext database;
public LoginController(Database database)
public LoginController(DatabaseContext database)
{
this.database = database;
}

View file

@ -1,4 +1,5 @@
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
@ -14,9 +15,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
public class LogoutController : ControllerBase
{
private readonly Database database;
private readonly DatabaseContext database;
public LogoutController(Database database)
public LogoutController(DatabaseContext database)
{
this.database = database;
}

View file

@ -1,4 +1,5 @@
#nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Types.Entities.Interaction;
@ -17,9 +18,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Matching;
[Produces("text/xml")]
public class EnterLevelController : ControllerBase
{
private readonly Database database;
private readonly DatabaseContext database;
public EnterLevelController(Database database)
public EnterLevelController(DatabaseContext database)
{
this.database = database;
}

View file

@ -1,5 +1,6 @@
#nullable enable
using System.Text.Json;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging;
@ -21,9 +22,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Matching;
[Produces("text/xml")]
public class MatchController : ControllerBase
{
private readonly Database database;
private readonly DatabaseContext database;
public MatchController(Database database)
public MatchController(DatabaseContext database)
{
this.database = database;
}

View file

@ -1,5 +1,6 @@
#nullable enable
using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging;
@ -18,7 +19,7 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
[Produces("text/plain")]
public class MessageController : ControllerBase
{
private readonly Database database;
private readonly DatabaseContext database;
private const string license = @"
This program is free software: you can redistribute it and/or modify
@ -34,7 +35,7 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.";
public MessageController(Database database)
public MessageController(DatabaseContext database)
{
this.database = database;
}

View file

@ -1,6 +1,7 @@
#nullable enable
using System.Text.Json;
using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Types.Entities.Moderation;
@ -17,9 +18,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
[Produces("text/xml")]
public class ReportController : ControllerBase
{
private readonly Database database;
private readonly DatabaseContext database;
public ReportController(Database database)
public ReportController(DatabaseContext database)
{
this.database = database;
}

View file

@ -1,6 +1,7 @@
#nullable enable
using Discord;
using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Files;
using LBPUnion.ProjectLighthouse.Helpers;
@ -23,9 +24,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Resources;
[Produces("text/xml")]
public class PhotosController : ControllerBase
{
private readonly Database database;
private readonly DatabaseContext database;
public PhotosController(Database database)
public PhotosController(DatabaseContext database)
{
this.database = database;
}

View file

@ -1,5 +1,6 @@
#nullable enable
using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Serialization;
@ -21,9 +22,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
[Produces("text/xml")]
public class CollectionController : ControllerBase
{
private readonly Database database;
private readonly DatabaseContext database;
public CollectionController(Database database)
public CollectionController(DatabaseContext database)
{
this.database = database;
}

View file

@ -1,3 +1,4 @@
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Types.Entities.Interaction;
@ -17,9 +18,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
[Produces("text/plain")]
public class LevelTagsController : ControllerBase
{
private readonly Database database;
private readonly DatabaseContext database;
public LevelTagsController(Database database)
public LevelTagsController(DatabaseContext database)
{
this.database = database;
}

View file

@ -1,4 +1,5 @@
#nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Serialization;
@ -20,8 +21,8 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
[Produces("text/xml")]
public class ListController : ControllerBase
{
private readonly Database database;
public ListController(Database database)
private readonly DatabaseContext database;
public ListController(DatabaseContext database)
{
this.database = database;
}

View file

@ -1,5 +1,6 @@
#nullable enable
using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Files;
using LBPUnion.ProjectLighthouse.Helpers;
@ -24,9 +25,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
[Produces("text/xml")]
public class PublishController : ControllerBase
{
private readonly Database database;
private readonly DatabaseContext database;
public PublishController(Database database)
public PublishController(DatabaseContext database)
{
this.database = database;
}

View file

@ -1,4 +1,5 @@
#nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Serialization;
@ -18,9 +19,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
[Produces("text/xml")]
public class ReviewController : ControllerBase
{
private readonly Database database;
private readonly DatabaseContext database;
public ReviewController(Database database)
public ReviewController(DatabaseContext database)
{
this.database = database;
}

View file

@ -1,5 +1,6 @@
#nullable enable
using System.Diagnostics.CodeAnalysis;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Logging;
@ -22,9 +23,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
[Produces("text/xml")]
public class ScoreController : ControllerBase
{
private readonly Database database;
private readonly DatabaseContext database;
public ScoreController(Database database)
public ScoreController(DatabaseContext database)
{
this.database = database;
}

View file

@ -1,4 +1,5 @@
#nullable enable
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Serialization;
using LBPUnion.ProjectLighthouse.Types.Entities.Level;
@ -16,8 +17,8 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
[Produces("text/xml")]
public class SearchController : ControllerBase
{
private readonly Database database;
public SearchController(Database database)
private readonly DatabaseContext database;
public SearchController(DatabaseContext database)
{
this.database = database;
}

View file

@ -1,5 +1,6 @@
#nullable enable
using LBPUnion.ProjectLighthouse.Configuration;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Serialization;
@ -21,8 +22,8 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Slots;
[Produces("text/xml")]
public class SlotsController : ControllerBase
{
private readonly Database database;
public SlotsController(Database database)
private readonly DatabaseContext database;
public SlotsController(DatabaseContext database)
{
this.database = database;
}

View file

@ -1,3 +1,4 @@
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Serialization;
using Microsoft.AspNetCore.Authorization;
@ -13,9 +14,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
public class StatisticsController : ControllerBase
{
private readonly Database database;
private readonly DatabaseContext database;
public StatisticsController(Database database)
public StatisticsController(DatabaseContext database)
{
this.database = database;
}

View file

@ -1,5 +1,6 @@
#nullable enable
using System.Text.Json;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Files;
using LBPUnion.ProjectLighthouse.Helpers;
@ -23,9 +24,9 @@ namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers;
[Produces("text/xml")]
public class UserController : ControllerBase
{
private readonly Database database;
private readonly DatabaseContext database;
public UserController(Database database)
public UserController(DatabaseContext database)
{
this.database = database;
}