Implement sizeOfResources in Slot

Closes #45
This commit is contained in:
jvyden 2021-11-18 18:51:18 -05:00
commit 616649e96a
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
2 changed files with 5 additions and 1 deletions

View file

@ -78,6 +78,8 @@ namespace LBPUnion.ProjectLighthouse.Helpers
public static bool ResourceExists(string hash) => File.Exists(GetResourcePath(hash));
public static int ResourceSize(string hash) => (int)new FileInfo(GetResourcePath(hash)).Length;
public static void EnsureDirectoryCreated(string path)
{
if (!Directory.Exists(path)) Directory.CreateDirectory(path ?? throw new ArgumentNullException(nameof(path)));

View file

@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Xml.Serialization;
using LBPUnion.ProjectLighthouse.Helpers;
using LBPUnion.ProjectLighthouse.Serialization;
using LBPUnion.ProjectLighthouse.Types.Profiles;
@ -195,7 +196,8 @@ namespace LBPUnion.ProjectLighthouse.Types.Levels
public string SerializeResources()
{
return this.Resources.Aggregate("", (current, resource) => current + LbpSerializer.StringElement("resource", resource));
return this.Resources.Aggregate("", (current, resource) => current + LbpSerializer.StringElement("resource", resource)) +
LbpSerializer.StringElement("sizeOfResources", this.Resources.Sum(FileHelper.ResourceSize));
}
public string Serialize(RatedLevel? yourRatingStats = null, VisitedLevel? yourVisitedStats = null)