using System;
namespace Masuit.Tools.DateTimeExt
{
///
/// 节假日信息
///
public readonly record struct WeekHolidayStruct : IEquatable
{
///
/// 月
///
public readonly int Month;
///
/// 这个月第几周
///
public readonly int WeekAtMonth;
///
/// 周末日
///
public readonly int WeekDay;
///
/// 假日名
///
public readonly string HolidayName;
///
/// 节假日信息
///
///
///
///
///
public WeekHolidayStruct(int month, int weekAtMonth, int weekDay, string name)
{
Month = month;
WeekAtMonth = weekAtMonth;
WeekDay = weekDay;
HolidayName = name;
}
/// 指示当前对象是否等于同一类型的另一个对象。
/// 一个与此对象进行比较的对象。
/// 如果当前对象等于 参数,则为 true;否则为 false。
public bool Equals(WeekHolidayStruct other)
{
return Month == other.Month && WeekAtMonth == other.WeekAtMonth && WeekDay == other.WeekDay && HolidayName == other.HolidayName;
}
/// 返回此实例的哈希代码。
/// 一个 32 位带符号整数,它是此实例的哈希代码。
public override int GetHashCode()
{
unchecked
{
var hashCode = Month;
hashCode = (hashCode * 397) ^ WeekAtMonth;
hashCode = (hashCode * 397) ^ WeekDay;
hashCode = (hashCode * 397) ^ (HolidayName != null ? HolidayName.GetHashCode() : 0);
return hashCode;
}
}
}
}