61 lines
2.0 KiB
C#
61 lines
2.0 KiB
C#
using System.Collections.Generic;
|
||
|
||
namespace HashCalculator.GUI
|
||
{
|
||
internal enum InputEntryType
|
||
{
|
||
Text,
|
||
BigFile,
|
||
ManifestFile,
|
||
XmlFile,
|
||
XsdFile,
|
||
BinaryFile,
|
||
Path,
|
||
}
|
||
|
||
internal sealed class InputEntry
|
||
{
|
||
public static IReadOnlyDictionary<InputEntryType, string> Descriptions = new Dictionary<InputEntryType, string>
|
||
{
|
||
{ InputEntryType.BigFile, "可以尝试读取这个 big 文件里的 manifest 文件" },
|
||
{ InputEntryType.BinaryFile, "可以计算这个文件的哈希值" },
|
||
{ InputEntryType.ManifestFile, "可以尝试读取这个 manifest 文件,显示各个素材的哈希值" },
|
||
{ InputEntryType.XmlFile, "可以尝试读取这个 XML,显示 XML 里定义的各个素材的哈希值" },
|
||
{ InputEntryType.XsdFile, "可以尝试读取 XSD,显示 XSD 里定义的各个素材的哈希值" },
|
||
{ 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;
|
||
}
|
||
}
|
||
}
|