using System; using System.Collections.Generic; using System.Text; using System.Threading.Tasks; using TechnologyAssembler.Core.IO; namespace HashCalculator.GUI { internal enum InputEntryType { Text, BigFile, ManifestFile, XmlFile, BinaryFile, Path, } internal sealed class InputEntry { public static IReadOnlyDictionary Descriptions = new Dictionary { { InputEntryType.BigFile, "可以尝试读取这个 big 文件里的 manifest 文件" }, { InputEntryType.BinaryFile, "可以计算这个文件的哈希值" }, { InputEntryType.ManifestFile, "可以尝试读取这个 manifest 文件,显示各个素材的哈希值" }, { InputEntryType.XmlFile, "可以尝试读取这个XML,显示 XML 里定义的各个素材的哈希值" }, { InputEntryType.Path, string.Empty }, }; public InputEntryType Type { get; } public string Value { get; } public string Text { get; } public string Details { get { if(Type == InputEntryType.Text) { var hash = SageHash.CalculateLowercaseHash(Value); var binaryHash = SageHash.CalculateBinaryHash(Value); return hash == binaryHash ? $"这段文字的哈希值:{hash:x8} ({hash})" : $"这段文字的哈希值:{hash:x8};大小写敏感哈希值 {binaryHash:x8}"; } return Descriptions[Type]; } } public bool IsValid => Type != InputEntryType.Text && Type != InputEntryType.Path; public InputEntry(InputEntryType type, string text, string value) { Type = type; Text = text; Value = value; } public override string ToString() { return Text; } } }