using System; using System.Collections.Generic; using System.Text; namespace Apewer.Models { /// 文本字段。 [Serializable] public sealed class TextField { /// 名称。 public string Name { get; set; } /// 值。 public string Value { get; set; } /// 文本字段。 public TextField() { } /// 创建文本字段。 public TextField(string name, string value) { this.Name = name; this.Value = value; } /// 创建文本字段。 public TextField(KeyValuePair pair) { this.Name = pair.Key; this.Value = pair.Value; } /// public override string ToString() => $"{Name} = {Value}"; /// public override bool Equals(object obj) { if (obj != null && obj is TextField field) return field.Name == Name && field.Value == Value; return false; } /// public override int GetHashCode() => (Name ?? "").GetHashCode() ^ (Value ?? "").GetHashCode(); /// public static implicit operator KeyValuePair(TextField field) => field == null ? default : new KeyValuePair(field.Name, field.Value); /// public static implicit operator TextField(KeyValuePair pair) => new KeyValuePair(pair.Key, pair.Value); } }