diff --git a/ProjectLighthouse/Controllers/NetworkSettingsController.cs b/ProjectLighthouse/Controllers/NetworkSettingsController.cs index 0cb8e39c..9329593a 100644 --- a/ProjectLighthouse/Controllers/NetworkSettingsController.cs +++ b/ProjectLighthouse/Controllers/NetworkSettingsController.cs @@ -8,7 +8,7 @@ namespace ProjectLighthouse.Controllers { public class NetworkSettingsController : ControllerBase { [HttpGet] public IActionResult Get() { - return this.Ok(LbpSerializer.GetBlankElement("networkSettings")); + return this.Ok(LbpSerializer.BlankElement("networkSettings")); } } } \ No newline at end of file diff --git a/ProjectLighthouse/Controllers/NewsController.cs b/ProjectLighthouse/Controllers/NewsController.cs index b81304c2..4fc3216e 100644 --- a/ProjectLighthouse/Controllers/NewsController.cs +++ b/ProjectLighthouse/Controllers/NewsController.cs @@ -9,7 +9,7 @@ namespace ProjectLighthouse.Controllers { public class NewsController : ControllerBase { [HttpGet] public IActionResult Get() { - string newsEntry = LbpSerializer.GetStringElement("item", new NewsEntry { + string newsEntry = LbpSerializer.StringElement("item", new NewsEntry { Category = "no_category", Summary = "test summary", Image = new NewsImage { @@ -22,7 +22,7 @@ namespace ProjectLighthouse.Controllers { Date = 1348755214000 }.Serialize()); - return this.Ok(LbpSerializer.GetStringElement("news", newsEntry)); + return this.Ok(LbpSerializer.StringElement("news", newsEntry)); } } } \ No newline at end of file diff --git a/ProjectLighthouse/Serialization/LbpSerializer.cs b/ProjectLighthouse/Serialization/LbpSerializer.cs index b939aac1..c97ec520 100644 --- a/ProjectLighthouse/Serialization/LbpSerializer.cs +++ b/ProjectLighthouse/Serialization/LbpSerializer.cs @@ -5,19 +5,19 @@ using System.Reflection; namespace ProjectLighthouse.Serialization { public static class LbpSerializer { - public static string GetBlankElement(string key) => $"<{key}>"; + public static string BlankElement(string key) => $"<{key}>"; - public static string GetStringElement(KeyValuePair pair) => $"<{pair.Key}>{pair.Value}"; + public static string StringElement(KeyValuePair pair) => $"<{pair.Key}>{pair.Value}"; - public static string GetStringElement(string key, object value) => $"<{key}>{value}"; + public static string StringElement(string key, object value) => $"<{key}>{value}"; - public static string GetTaggedStringElement(KeyValuePair pair, KeyValuePair tagPair) => + public static string TaggedStringElement(KeyValuePair pair, KeyValuePair tagPair) => $"<{pair.Key} {tagPair.Key}=\"{tagPair.Value}\">{pair.Value}"; - public static string GetTaggedStringElement(string key, object value, string tagKey, object tagValue) => + public static string TaggedStringElement(string key, object value, string tagKey, object tagValue) => $"<{key} {tagKey}=\"{tagValue}\">{value}"; - public static string GetElements(params KeyValuePair[] pairs) => - pairs.Aggregate(string.Empty, (current, pair) => current + GetStringElement(pair)); + public static string Elements(params KeyValuePair[] pairs) => + pairs.Aggregate(string.Empty, (current, pair) => current + StringElement(pair)); } } \ No newline at end of file diff --git a/ProjectLighthouse/Types/ClientsConnected.cs b/ProjectLighthouse/Types/ClientsConnected.cs index 5b9a2e27..aed02acc 100644 --- a/ProjectLighthouse/Types/ClientsConnected.cs +++ b/ProjectLighthouse/Types/ClientsConnected.cs @@ -9,12 +9,12 @@ namespace ProjectLighthouse.Types { public bool Lbp3Ps4 { get; set; } public string Serialize() { - return LbpSerializer.GetStringElement("clientsConnected", - LbpSerializer.GetStringElement("lbp1", Lbp1) + - LbpSerializer.GetStringElement("lbp2", Lbp2) + - LbpSerializer.GetStringElement("lbpme", LbpMe) + - LbpSerializer.GetStringElement("lbp3ps3", Lbp3Ps3) + - LbpSerializer.GetStringElement("lbp3ps4", Lbp3Ps4)); + return LbpSerializer.StringElement("clientsConnected", + LbpSerializer.StringElement("lbp1", Lbp1) + + LbpSerializer.StringElement("lbp2", Lbp2) + + LbpSerializer.StringElement("lbpme", LbpMe) + + LbpSerializer.StringElement("lbp3ps3", Lbp3Ps3) + + LbpSerializer.StringElement("lbp3ps4", Lbp3Ps4)); } } } \ No newline at end of file diff --git a/ProjectLighthouse/Types/Location.cs b/ProjectLighthouse/Types/Location.cs index 53dcec0b..78a7f6cf 100644 --- a/ProjectLighthouse/Types/Location.cs +++ b/ProjectLighthouse/Types/Location.cs @@ -6,8 +6,8 @@ namespace ProjectLighthouse.Types { public int Y; public string Serialize() { - return LbpSerializer.GetStringElement("x", this.X) + - LbpSerializer.GetStringElement("Y", this.Y); + return LbpSerializer.StringElement("x", this.X) + + LbpSerializer.StringElement("Y", this.Y); } } } \ No newline at end of file diff --git a/ProjectLighthouse/Types/LoginResult.cs b/ProjectLighthouse/Types/LoginResult.cs index 84a07e2e..991c9c11 100644 --- a/ProjectLighthouse/Types/LoginResult.cs +++ b/ProjectLighthouse/Types/LoginResult.cs @@ -7,7 +7,7 @@ namespace ProjectLighthouse.Types { public string LbpEnvVer { get; set; } public string Serialize() { - return LbpSerializer.GetElements( + return LbpSerializer.Elements( new KeyValuePair("authTicket", this.AuthTicket), new KeyValuePair("lbpEnvVer", this.LbpEnvVer) ); diff --git a/ProjectLighthouse/Types/NewsEntry.cs b/ProjectLighthouse/Types/NewsEntry.cs index 8a701787..5cf0ad35 100644 --- a/ProjectLighthouse/Types/NewsEntry.cs +++ b/ProjectLighthouse/Types/NewsEntry.cs @@ -11,13 +11,13 @@ namespace ProjectLighthouse.Types { public long Date { get; set; } public string Serialize() { - return LbpSerializer.GetStringElement("id", this.Id) + - LbpSerializer.GetStringElement("title", this.Title) + - LbpSerializer.GetStringElement("summary", this.Summary) + - LbpSerializer.GetStringElement("text", this.Text) + - LbpSerializer.GetStringElement("date", this.Date) + + return LbpSerializer.StringElement("id", this.Id) + + LbpSerializer.StringElement("title", this.Title) + + LbpSerializer.StringElement("summary", this.Summary) + + LbpSerializer.StringElement("text", this.Text) + + LbpSerializer.StringElement("date", this.Date) + this.Image.Serialize() + - LbpSerializer.GetStringElement("category", this.Category); + LbpSerializer.StringElement("category", this.Category); } } } \ No newline at end of file diff --git a/ProjectLighthouse/Types/NewsImage.cs b/ProjectLighthouse/Types/NewsImage.cs index fa97c8eb..4c6fd95a 100644 --- a/ProjectLighthouse/Types/NewsImage.cs +++ b/ProjectLighthouse/Types/NewsImage.cs @@ -6,9 +6,9 @@ namespace ProjectLighthouse.Types { public string Alignment { get; set; } public string Serialize() { - return LbpSerializer.GetStringElement("image", - LbpSerializer.GetStringElement("hash", this.Hash) + - LbpSerializer.GetStringElement("alignment", this.Alignment)); + return LbpSerializer.StringElement("image", + LbpSerializer.StringElement("hash", this.Hash) + + LbpSerializer.StringElement("alignment", this.Alignment)); } } } \ No newline at end of file diff --git a/ProjectLighthouse/Types/User.cs b/ProjectLighthouse/Types/User.cs index eb9970bd..b8c37b65 100644 --- a/ProjectLighthouse/Types/User.cs +++ b/ProjectLighthouse/Types/User.cs @@ -45,12 +45,12 @@ namespace ProjectLighthouse.Types { foreach(string s in slotTypes) { string slotType = s; // vars in foreach are immutable, define helper var - slots += LbpSerializer.GetStringElement(slotType + "UsedSlots", this.UsedSlots); + slots += LbpSerializer.StringElement(slotType + "UsedSlots", this.UsedSlots); if(slotType == "lbp1") slotType = ""; - slots += LbpSerializer.GetStringElement(slotType + "EntitledSlots", EntitledSlots); + slots += LbpSerializer.StringElement(slotType + "EntitledSlots", EntitledSlots); // ReSharper disable once StringLiteralTypo - slots += LbpSerializer.GetStringElement(slotType + slotType == "crossControl" ? "PurchsedSlots" : "PurchasedSlots", 0); - slots += LbpSerializer.GetStringElement(slotType + "FreeSlots", this.FreeSlots); + slots += LbpSerializer.StringElement(slotType + slotType == "crossControl" ? "PurchsedSlots" : "PurchasedSlots", 0); + slots += LbpSerializer.StringElement(slotType + "FreeSlots", this.FreeSlots); } return slots; @@ -59,32 +59,32 @@ namespace ProjectLighthouse.Types { #endregion Slots public string Serialize() { - string user = LbpSerializer.GetTaggedStringElement("npHandle", this.Username, "icon", this.IconHash) + - LbpSerializer.GetStringElement("game", this.Game) + + string user = LbpSerializer.TaggedStringElement("npHandle", this.Username, "icon", this.IconHash) + + LbpSerializer.StringElement("game", this.Game) + this.SerializeSlots() + - LbpSerializer.GetStringElement("lists", this.Lists) + - LbpSerializer.GetStringElement("lists_quota", ListsQuota) + - LbpSerializer.GetStringElement("heartCount", this.HeartCount) + - LbpSerializer.GetStringElement("yay2", this.YayHash) + - LbpSerializer.GetStringElement("boo2", this.BooHash) + - LbpSerializer.GetStringElement("biography", this.Biography) + - LbpSerializer.GetStringElement("reviewCount", this.ReviewCount) + - LbpSerializer.GetStringElement("commentCount", this.CommentCount) + - LbpSerializer.GetStringElement("photosByMeCount", this.PhotosByMeCount) + - LbpSerializer.GetStringElement("photosWithMeCount", this.PhotosWithMeCount) + - LbpSerializer.GetStringElement("commentsEnabled", this.CommentsEnabled) + + LbpSerializer.StringElement("lists", this.Lists) + + LbpSerializer.StringElement("lists_quota", ListsQuota) + + LbpSerializer.StringElement("heartCount", this.HeartCount) + + LbpSerializer.StringElement("yay2", this.YayHash) + + LbpSerializer.StringElement("boo2", this.BooHash) + + LbpSerializer.StringElement("biography", this.Biography) + + LbpSerializer.StringElement("reviewCount", this.ReviewCount) + + LbpSerializer.StringElement("commentCount", this.CommentCount) + + LbpSerializer.StringElement("photosByMeCount", this.PhotosByMeCount) + + LbpSerializer.StringElement("photosWithMeCount", this.PhotosWithMeCount) + + LbpSerializer.StringElement("commentsEnabled", this.CommentsEnabled) + this.Location.Serialize() + - LbpSerializer.GetStringElement("favouriteSlotCount", this.FavouriteSlotCount) + - LbpSerializer.GetStringElement("favouriteUserCount", this.FavouriteUserCount) + - LbpSerializer.GetStringElement("lolcatftwCount", this.lolcatftwCount) + - LbpSerializer.GetStringElement("pins", this.Pins) + - LbpSerializer.GetStringElement("staffChallengeGoldCount", this.StaffChallengeGoldCount) + - LbpSerializer.GetStringElement("staffChallengeSilverCount", this.StaffChallengeSilverCount) + - LbpSerializer.GetStringElement("staffChallengeBronzeCount", this.StaffChallengeBronzeCount) + - LbpSerializer.GetStringElement("photos", "") + + LbpSerializer.StringElement("favouriteSlotCount", this.FavouriteSlotCount) + + LbpSerializer.StringElement("favouriteUserCount", this.FavouriteUserCount) + + LbpSerializer.StringElement("lolcatftwCount", this.lolcatftwCount) + + LbpSerializer.StringElement("pins", this.Pins) + + LbpSerializer.StringElement("staffChallengeGoldCount", this.StaffChallengeGoldCount) + + LbpSerializer.StringElement("staffChallengeSilverCount", this.StaffChallengeSilverCount) + + LbpSerializer.StringElement("staffChallengeBronzeCount", this.StaffChallengeBronzeCount) + + LbpSerializer.StringElement("photos", "") + this.ClientsConnected.Serialize(); - return LbpSerializer.GetTaggedStringElement("user", user, "type", "user"); + return LbpSerializer.TaggedStringElement("user", user, "type", "user"); } } } \ No newline at end of file