using System; using System.Net; namespace FastGithub.Scanner { sealed class GithubContext : IEquatable { private record Github( string Domain, IPAddress Address, double SuccessRate, TimeSpan AvgElapsed); /// /// 获取域名 /// public string Domain { get; } /// /// 获取ip /// public IPAddress Address { get; } /// /// 获取或设置是否可用 /// public bool Available { get; set; } /// /// 获取扫描历史信息 /// public GithubContextHistory History { get; } = new(); public GithubContext(string domain, IPAddress address) { this.Domain = domain; this.Address = address; } public override bool Equals(object? obj) { return obj is GithubContext other && this.Equals(other); } public bool Equals(GithubContext? other) { return other != null && other.Address.Equals(this.Address) && other.Domain == this.Domain; } public override int GetHashCode() { return HashCode.Combine(this.Domain, this.Address); } public override string ToString() { return new Github( this.Domain, this.Address, this.History.GetSuccessRate(), this.History.GetAvgElapsed() ).ToString(); } } }