Remove Get from LbpSerializer methods

This commit is contained in:
jvyden 2021-10-06 02:29:55 -04:00
commit c3257158da
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
9 changed files with 54 additions and 54 deletions

View file

@ -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"));
}
}
}

View file

@ -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));
}
}
}

View file

@ -5,19 +5,19 @@ using System.Reflection;
namespace ProjectLighthouse.Serialization {
public static class LbpSerializer {
public static string GetBlankElement(string key) => $"<{key}></{key}>";
public static string BlankElement(string key) => $"<{key}></{key}>";
public static string GetStringElement(KeyValuePair<string, object> pair) => $"<{pair.Key}>{pair.Value}</{pair.Key}>";
public static string StringElement(KeyValuePair<string, object> pair) => $"<{pair.Key}>{pair.Value}</{pair.Key}>";
public static string GetStringElement(string key, object value) => $"<{key}>{value}</{key}>";
public static string StringElement(string key, object value) => $"<{key}>{value}</{key}>";
public static string GetTaggedStringElement(KeyValuePair<string, object> pair, KeyValuePair<string, object> tagPair) =>
public static string TaggedStringElement(KeyValuePair<string, object> pair, KeyValuePair<string, object> tagPair) =>
$"<{pair.Key} {tagPair.Key}=\"{tagPair.Value}\">{pair.Value}</{pair.Key}>";
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}</{key}>";
public static string GetElements(params KeyValuePair<string, object>[] pairs) =>
pairs.Aggregate(string.Empty, (current, pair) => current + GetStringElement(pair));
public static string Elements(params KeyValuePair<string, object>[] pairs) =>
pairs.Aggregate(string.Empty, (current, pair) => current + StringElement(pair));
}
}

View file

@ -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));
}
}
}

View file

@ -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);
}
}
}

View file

@ -7,7 +7,7 @@ namespace ProjectLighthouse.Types {
public string LbpEnvVer { get; set; }
public string Serialize() {
return LbpSerializer.GetElements(
return LbpSerializer.Elements(
new KeyValuePair<string, object>("authTicket", this.AuthTicket),
new KeyValuePair<string, object>("lbpEnvVer", this.LbpEnvVer)
);

View file

@ -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);
}
}
}

View file

@ -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));
}
}
}

View file

@ -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");
}
}
}