using System; using System.Collections; using System.Collections.Generic; namespace YooAsset.Editor { [Serializable] public class ScanReport { /// /// 文件签名(自动填写) /// public string FileSign; /// /// 文件版本(自动填写) /// public string FileVersion; /// /// 模式类型(自动填写) /// public string SchemaType; /// /// 扫描器GUID(自动填写) /// public string ScannerGUID; /// /// 报告名称 /// public string ReportName; /// /// 报告介绍 /// public string ReportDesc; /// /// 报告的标题列表 /// public List ReportHeaders = new List(); /// /// 扫描的元素列表 /// public List ReportElements = new List(); public ScanReport(string reportName, string reportDesc) { ReportName = reportName; ReportDesc = reportDesc; } /// /// 添加标题 /// public ReportHeader AddHeader(string headerTitle, int width) { var reportHeader = new ReportHeader(headerTitle, width); ReportHeaders.Add(reportHeader); return reportHeader; } /// /// 添加标题 /// public ReportHeader AddHeader(string headerTitle, int width, int minWidth, int maxWidth) { var reportHeader = new ReportHeader(headerTitle, width, minWidth, maxWidth); ReportHeaders.Add(reportHeader); return reportHeader; } /// /// 检测错误 /// public void CheckError() { // 检测标题 Dictionary headerMap = new Dictionary(); foreach (var header in ReportHeaders) { string headerTitle = header.HeaderTitle; if (headerMap.ContainsKey(headerTitle)) throw new Exception($"The header title {headerTitle} already exists !"); else headerMap.Add(headerTitle, header); } // 检测扫描元素 HashSet elementMap = new HashSet(); foreach (var element in ReportElements) { if (string.IsNullOrEmpty(element.GUID)) throw new Exception($"The report element GUID is null or empty !"); if (elementMap.Contains(element.GUID)) throw new Exception($"The report element GUID already exists ! {element.GUID}"); else elementMap.Add(element.GUID); foreach (var scanInfo in element.ScanInfos) { if (headerMap.ContainsKey(scanInfo.HeaderTitle) == false) throw new Exception($"The report element header {scanInfo.HeaderTitle} is missing !"); // 检测数值有效性 var header = headerMap[scanInfo.HeaderTitle]; header.CheckValueValid(scanInfo.ScanInfo); } } } } }