This repository has been archived on 2025-08-02. You can view files and clone it, but cannot push or open issues or pull requests.
Files
Cryville.EEW.Unity/Assets/Cryville.EEW.Unity/UI/Localized.cs
2025-02-14 16:06:00 +08:00

24 lines
900 B
C#

using System;
using System.Collections.Generic;
using System.Globalization;
namespace Cryville.EEW.Unity.UI {
struct Localized<T> : IEquatable<Localized<T>> {
public T Value { get; set; }
public CultureInfo Culture { get; set; }
public Localized(T value, CultureInfo culture) {
Value = value;
Culture = culture;
}
public override readonly bool Equals(object obj) => obj is Localized<T> localized && Equals(localized);
public readonly bool Equals(Localized<T> other) =>
EqualityComparer<T>.Default.Equals(Value, other.Value) &&
EqualityComparer<CultureInfo>.Default.Equals(Culture, other.Culture);
public override readonly int GetHashCode() => HashCode.Combine(Value, Culture);
public static bool operator ==(Localized<T> left, Localized<T> right) => left.Equals(right);
public static bool operator !=(Localized<T> left, Localized<T> right) => !(left == right);
}
}