using System; using System.Collections.Generic; namespace JD.EngineLogger.Models { public class WarningEntry { public uint ObjectRef { get; private set; } public string Name { get; private set; } public string Message { get; private set; } public string Category { get; private set; } public string Scene { get; private set; } public static WarningEntry LoadFromBlob(JD.Remoting.IBlob blob) { WarningEntry warningEntry = new WarningEntry { ObjectRef = blob.ExtractUInt(), Name = blob.ExtractString(), Message = blob.ExtractString().TrimStart('?'), Category = blob.ExtractString(), Scene = blob.ExtractString() }; return warningEntry; } public Plume.ErrorList.Model.LogEntry ToErrorListEntry() { string category = ""; if (!string.IsNullOrEmpty(Category) && !string.IsNullOrEmpty(Name)) { category = $"{Category},{Name}"; } else if (!string.IsNullOrEmpty(Category)) { category = Category; } else if(!string.IsNullOrEmpty(Name)) { category = Name; } return new Plume.ErrorList.Model.LogEntry(Message, Plume.ErrorList.Model.LogLevel.Warning, category, DateTime.Now); } public Plume.Output.Model.LogEntry ToOutputEntry() { string category = ""; if (!string.IsNullOrEmpty(Category) && !string.IsNullOrEmpty(Name)) { category = $"{Category},{Name}"; } else if (!string.IsNullOrEmpty(Category)) { category = Category; } else if (!string.IsNullOrEmpty(Name)) { category = Name; } return new Plume.Output.Model.LogEntry(Message, Plume.Output.Model.LogLevel.Warning, category, DateTime.Now); } public static IEnumerable LoadMultipleFromBlob(JD.Remoting.IBlob blob) { uint warningCount = blob.ExtractUInt(); for (var i = 0; i < warningCount; i++) { yield return LoadFromBlob(blob); } } } }