You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.7 KiB
57 lines
1.7 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace Apewer.Models
|
|
{
|
|
|
|
/// <summary>文本字段。</summary>
|
|
[Serializable]
|
|
public sealed class TextField
|
|
{
|
|
|
|
/// <summary>名称。</summary>
|
|
public string Name { get; set; }
|
|
|
|
/// <summary>值。</summary>
|
|
public string Value { get; set; }
|
|
|
|
/// <summary>文本字段。</summary>
|
|
public TextField() { }
|
|
|
|
/// <summary>创建文本字段。</summary>
|
|
public TextField(string name, string value)
|
|
{
|
|
this.Name = name;
|
|
this.Value = value;
|
|
}
|
|
|
|
/// <summary>创建文本字段。</summary>
|
|
public TextField(KeyValuePair<string, string> pair)
|
|
{
|
|
this.Name = pair.Key;
|
|
this.Value = pair.Value;
|
|
}
|
|
|
|
/// <summary></summary>
|
|
public override string ToString() => $"{Name} = {Value}";
|
|
|
|
/// <summary></summary>
|
|
public override bool Equals(object obj)
|
|
{
|
|
if (obj != null && obj is TextField field) return field.Name == Name && field.Value == Value;
|
|
return false;
|
|
}
|
|
|
|
/// <summary></summary>
|
|
public override int GetHashCode() => (Name ?? "").GetHashCode() ^ (Value ?? "").GetHashCode();
|
|
|
|
/// <summary></summary>
|
|
public static implicit operator KeyValuePair<string, string>(TextField field) => field == null ? default : new KeyValuePair<string, string>(field.Name, field.Value);
|
|
|
|
/// <summary></summary>
|
|
public static implicit operator TextField(KeyValuePair<string, string> pair) => new KeyValuePair<string, string>(pair.Key, pair.Value);
|
|
|
|
}
|
|
|
|
}
|
|
|