Organize ProjectLighthouse.Types

This commit is contained in:
jvyden 2021-10-20 21:38:44 -04:00
parent 283266cd31
commit bf7bbab467
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
29 changed files with 62 additions and 39 deletions

View file

@ -1,5 +1,6 @@
using Microsoft.EntityFrameworkCore;
using ProjectLighthouse.Types;
using ProjectLighthouse.Types.Settings;
using Xunit;
namespace ProjectLighthouse.Tests {

View file

@ -2,6 +2,7 @@ using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using ProjectLighthouse.Types;
using ProjectLighthouse.Types.Settings;
using Xunit;
namespace ProjectLighthouse.Tests {

View file

@ -1,5 +1,7 @@
using System.Threading.Tasks;
using ProjectLighthouse.Types;
using ProjectLighthouse.Types.Levels;
using ProjectLighthouse.Types.Profiles;
using Xunit;
namespace ProjectLighthouse.Tests {

View file

@ -1,6 +1,7 @@
using System.Diagnostics.CodeAnalysis;
using Microsoft.AspNetCore.Mvc;
using ProjectLighthouse.Types;
using ProjectLighthouse.Types.Settings;
namespace ProjectLighthouse.Controllers {
[ApiController]

View file

@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using ProjectLighthouse.Serialization;
using ProjectLighthouse.Types;
using ProjectLighthouse.Types.Profiles;
namespace ProjectLighthouse.Controllers {
[ApiController]

View file

@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using ProjectLighthouse.Serialization;
using ProjectLighthouse.Types;
using ProjectLighthouse.Types.Levels;
namespace ProjectLighthouse.Controllers {
[ApiController]

View file

@ -1,6 +1,7 @@
using System;
using Microsoft.AspNetCore.Mvc;
using ProjectLighthouse.Types;
using ProjectLighthouse.Types.Levels;
namespace ProjectLighthouse.Controllers {
[ApiController]

View file

@ -3,6 +3,7 @@ using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using ProjectLighthouse.Types;
using ProjectLighthouse.Types.Settings;
namespace ProjectLighthouse.Controllers {
[ApiController]

View file

@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using ProjectLighthouse.Helpers;
using ProjectLighthouse.Types;
using ProjectLighthouse.Types.Profiles;
namespace ProjectLighthouse.Controllers {
[ApiController]

View file

@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using ProjectLighthouse.Serialization;
using ProjectLighthouse.Types;
using ProjectLighthouse.Types.News;
namespace ProjectLighthouse.Controllers {
[ApiController]

View file

@ -7,6 +7,8 @@ using Microsoft.EntityFrameworkCore;
using ProjectLighthouse.Helpers;
using ProjectLighthouse.Serialization;
using ProjectLighthouse.Types;
using ProjectLighthouse.Types.Levels;
using ProjectLighthouse.Types.Profiles;
namespace ProjectLighthouse.Controllers {
[ApiController]

View file

@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using ProjectLighthouse.Serialization;
using ProjectLighthouse.Types;
using ProjectLighthouse.Types.Levels;
namespace ProjectLighthouse.Controllers {
[ApiController]

View file

@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using ProjectLighthouse.Serialization;
using ProjectLighthouse.Types;
using ProjectLighthouse.Types.Levels;
namespace ProjectLighthouse.Controllers {
[ApiController]

View file

@ -6,6 +6,7 @@ using System.Xml;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using ProjectLighthouse.Types;
using ProjectLighthouse.Types.Profiles;
namespace ProjectLighthouse.Controllers {
[ApiController]

View file

@ -4,6 +4,9 @@ using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using ProjectLighthouse.Helpers;
using ProjectLighthouse.Types;
using ProjectLighthouse.Types.Levels;
using ProjectLighthouse.Types.Profiles;
using ProjectLighthouse.Types.Settings;
namespace ProjectLighthouse {
public class Database : DbContext {

View file

@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Hosting;
using ProjectLighthouse.Types;
using ProjectLighthouse.Types.Settings;
namespace ProjectLighthouse {
public static class Program {

View file

@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace ProjectLighthouse.Types {
namespace ProjectLighthouse.Types.Levels {
public class HeartedLevel {
// ReSharper disable once UnusedMember.Global
[Key] public int HeartedLevelId { get; set; }

View file

@ -1,6 +1,6 @@
using System.Diagnostics.CodeAnalysis;
namespace ProjectLighthouse.Types {
namespace ProjectLighthouse.Types.Levels {
/// <summary>
/// A series of tags that can be applied to a level
/// </summary>

View file

@ -1,7 +1,7 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace ProjectLighthouse.Types {
namespace ProjectLighthouse.Types.Levels {
public class QueuedLevel {
// ReSharper disable once UnusedMember.Global
[Key] public int QueuedLevelId { get; set; }

View file

@ -3,8 +3,9 @@ using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Xml.Serialization;
using ProjectLighthouse.Serialization;
using ProjectLighthouse.Types.Profiles;
namespace ProjectLighthouse.Types {
namespace ProjectLighthouse.Types.Levels {
/// <summary>
/// A LittleBigPlanet level.
/// </summary>
@ -90,23 +91,23 @@ namespace ProjectLighthouse.Types {
}
public string Serialize() {
string slotData = LbpSerializer.StringElement("name", Name) +
LbpSerializer.StringElement("id", SlotId) +
string slotData = LbpSerializer.StringElement("name", this.Name) +
LbpSerializer.StringElement("id", this.SlotId) +
LbpSerializer.StringElement("game", 1) +
LbpSerializer.StringElement("npHandle", Creator.Username) +
LbpSerializer.StringElement("description", Description) +
LbpSerializer.StringElement("icon", IconHash) +
LbpSerializer.StringElement("rootLevel", RootLevel) +
LbpSerializer.StringElement("npHandle", this.Creator.Username) +
LbpSerializer.StringElement("description", this.Description) +
LbpSerializer.StringElement("icon", this.IconHash) +
LbpSerializer.StringElement("rootLevel", this.RootLevel) +
this.SerializeResources() +
LbpSerializer.StringElement("location", Location.Serialize()) +
LbpSerializer.StringElement("initiallyLocked", InitiallyLocked) +
LbpSerializer.StringElement("isSubLevel", SubLevel) +
LbpSerializer.StringElement("isLBP1Only", Lbp1Only) +
LbpSerializer.StringElement("shareable", Shareable) +
LbpSerializer.StringElement("background", BackgroundHash) +
LbpSerializer.StringElement("minPlayers", MinimumPlayers) +
LbpSerializer.StringElement("maxPlayers", MaximumPlayers) +
LbpSerializer.StringElement("moveRequired", MoveRequired);
LbpSerializer.StringElement("location", this.Location.Serialize()) +
LbpSerializer.StringElement("initiallyLocked", this.InitiallyLocked) +
LbpSerializer.StringElement("isSubLevel", this.SubLevel) +
LbpSerializer.StringElement("isLBP1Only", this.Lbp1Only) +
LbpSerializer.StringElement("shareable", this.Shareable) +
LbpSerializer.StringElement("background", this.BackgroundHash) +
LbpSerializer.StringElement("minPlayers", this.MinimumPlayers) +
LbpSerializer.StringElement("maxPlayers", this.MaximumPlayers) +
LbpSerializer.StringElement("moveRequired", this.MoveRequired);
return LbpSerializer.TaggedStringElement("slot", slotData, "type", "user");
}

View file

@ -1,6 +1,6 @@
using ProjectLighthouse.Serialization;
namespace ProjectLighthouse.Types {
namespace ProjectLighthouse.Types.News {
/// <summary>
/// Used on the info moon on LBP1. Broken for unknown reasons
/// </summary>

View file

@ -1,6 +1,6 @@
using ProjectLighthouse.Serialization;
namespace ProjectLighthouse.Types {
namespace ProjectLighthouse.Types.News {
public class NewsImage {
public string Hash { get; set; }
public string Alignment { get; set; }

View file

@ -1,7 +1,7 @@
using Microsoft.EntityFrameworkCore;
using ProjectLighthouse.Serialization;
namespace ProjectLighthouse.Types {
namespace ProjectLighthouse.Types.Profiles {
[Keyless]
public class ClientsConnected {
public bool Lbp1 { get; set; }
@ -12,11 +12,11 @@ namespace ProjectLighthouse.Types {
public string Serialize() {
return LbpSerializer.StringElement("clientsConnected",
LbpSerializer.StringElement("lbp1", Lbp1) +
LbpSerializer.StringElement("lbp2", Lbp2) +
LbpSerializer.StringElement("lbpme", LbpMe) +
LbpSerializer.StringElement("lbp3ps3", Lbp3Ps3) +
LbpSerializer.StringElement("lbp3ps4", Lbp3Ps4));
LbpSerializer.StringElement("lbp1", this.Lbp1) +
LbpSerializer.StringElement("lbp2", this.Lbp2) +
LbpSerializer.StringElement("lbpme", this.LbpMe) +
LbpSerializer.StringElement("lbp3ps3", this.Lbp3Ps3) +
LbpSerializer.StringElement("lbp3ps4", this.Lbp3Ps4));
}
}
}

View file

@ -3,7 +3,7 @@ using System.ComponentModel.DataAnnotations.Schema;
using System.Xml.Serialization;
using ProjectLighthouse.Serialization;
namespace ProjectLighthouse.Types {
namespace ProjectLighthouse.Types.Profiles {
[XmlRoot("comment"), XmlType("comment")]
public class Comment {
[Key]
@ -28,12 +28,12 @@ namespace ProjectLighthouse.Types {
public int ThumbsDown { get; set; }
private string serialize() {
return LbpSerializer.StringElement("id", CommentId) +
return LbpSerializer.StringElement("id", this.CommentId) +
LbpSerializer.StringElement("npHandle", this.Poster.Username) +
LbpSerializer.StringElement("timestamp", Timestamp) +
LbpSerializer.StringElement("message", Message) +
LbpSerializer.StringElement("thumbsup", ThumbsUp) +
LbpSerializer.StringElement("thumbsdown", ThumbsDown);
LbpSerializer.StringElement("timestamp", this.Timestamp) +
LbpSerializer.StringElement("message", this.Message) +
LbpSerializer.StringElement("thumbsup", this.ThumbsUp) +
LbpSerializer.StringElement("thumbsdown", this.ThumbsDown);
}
public string Serialize(int yourThumb) {

View file

@ -1,6 +1,6 @@
using System.ComponentModel.DataAnnotations;
namespace ProjectLighthouse.Types {
namespace ProjectLighthouse.Types.Profiles {
public class LastMatch {
[Key] public int UserId { get; set; }
public long Timestamp { get; set; }

View file

@ -1,6 +1,6 @@
using ProjectLighthouse.Serialization;
namespace ProjectLighthouse.Types {
namespace ProjectLighthouse.Types.Profiles {
/// <summary>
/// The location of a slot on a planet.
/// </summary>

View file

@ -1,14 +1,14 @@
using ProjectLighthouse.Serialization;
namespace ProjectLighthouse.Types {
namespace ProjectLighthouse.Types.Settings {
public class PrivacySettings {
public string LevelVisibility { get; set; }
public string ProfileVisibility { get; set; }
public string Serialize() {
return LbpSerializer.StringElement("privacySettings",
LbpSerializer.StringElement("levelVisibility", LevelVisibility) +
LbpSerializer.StringElement("profileVisibility", ProfileVisibility)
LbpSerializer.StringElement("levelVisibility", this.LevelVisibility) +
LbpSerializer.StringElement("profileVisibility", this.ProfileVisibility)
);
}
}

View file

@ -1,7 +1,7 @@
#nullable enable
using System;
namespace ProjectLighthouse.Types {
namespace ProjectLighthouse.Types.Settings {
public static class ServerSettings {
/// <summary>
/// The maximum amount of slots allowed on users' earth

View file

@ -1,5 +1,7 @@
using System.ComponentModel.DataAnnotations.Schema;
using ProjectLighthouse.Serialization;
using ProjectLighthouse.Types.Profiles;
using ProjectLighthouse.Types.Settings;
namespace ProjectLighthouse.Types {
public class User {