using System; using System.Collections.Generic; using System.Linq; using System.Text.Json.Serialization; namespace GeViSetEditor.Core.Models { /// /// Complete representation of a .set file with full structure /// Supports JSON serialization and round-trip conversion /// public class SetFileComplete { [JsonPropertyName("version")] public string Version { get; set; } = "1.0"; [JsonPropertyName("fileSize")] public int FileSize { get; set; } [JsonPropertyName("headerNullByte")] public bool HeaderNullByte { get; set; } [JsonPropertyName("header")] public string Header { get; set; } = ""; [JsonPropertyName("sections")] public List Sections { get; set; } = new(); /// /// Original raw data (not serialized to JSON) /// [JsonIgnore] public byte[] RawData { get; set; } /// /// Get statistics about the configuration /// [JsonIgnore] public ConfigStatisticsComplete Statistics => new ConfigStatisticsComplete { TotalSections = Sections.Count, TotalItems = Sections.Sum(s => s.Items.Count), TotalRules = Sections.Sum(s => s.Rules.Count), TotalActions = Sections.Sum(s => s.Rules.Sum(r => r.Actions.Count)), SectionTypes = Sections.GroupBy(s => s.Name) .ToDictionary(g => g.Key, g => g.Count()) }; } /// /// Complete section with all items and rules /// public class SectionComplete { [JsonPropertyName("name")] public string Name { get; set; } = ""; [JsonPropertyName("fileOffset")] public int FileOffset { get; set; } [JsonPropertyName("fileEndOffset")] public int FileEndOffset { get; set; } [JsonPropertyName("items")] public List Items { get; set; } = new(); [JsonPropertyName("rules")] public List Rules { get; set; } = new(); [JsonIgnore] public int ByteSize => FileEndOffset - FileOffset; } /// /// Configuration item (key-value pair) /// public class ConfigItemComplete { [JsonPropertyName("key")] public string Key { get; set; } = ""; [JsonPropertyName("value")] public object Value { get; set; } [JsonPropertyName("valueType")] public string ValueType { get; set; } = ""; [JsonPropertyName("fileOffset")] public int FileOffset { get; set; } } /// /// Action rule (trigger → actions) /// public class ActionRuleComplete { [JsonPropertyName("id")] public int RuleId { get; set; } [JsonPropertyName("fileOffset")] public int FileOffset { get; set; } [JsonPropertyName("triggers")] public Dictionary Triggers { get; set; } = new(); [JsonPropertyName("actions")] public List Actions { get; set; } = new(); [JsonPropertyName("metadata")] public Dictionary Metadata { get; set; } = new(); } /// /// Configuration statistics (Complete parser version) /// public class ConfigStatisticsComplete { [JsonPropertyName("totalSections")] public int TotalSections { get; set; } [JsonPropertyName("totalItems")] public int TotalItems { get; set; } [JsonPropertyName("totalRules")] public int TotalRules { get; set; } [JsonPropertyName("totalActions")] public int TotalActions { get; set; } [JsonPropertyName("sectionTypes")] public Dictionary SectionTypes { get; set; } = new(); } }