HashCalculator.GUI/InputEntry.cs
2020-03-28 23:16:45 +01:00

64 lines
2.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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<InputEntryType, string> Descriptions = new Dictionary<InputEntryType, string>
{
{ 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;
}
}
}