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);
	}
}
