namespace VideoBrowser.Common { using System; using VideoBrowser.Extensions; /// /// Defines the /// internal struct Percentage : IEquatable { /// /// Initializes a new instance of the class. /// /// The percent public Percentage(double percent) { this.Percent = percent; } /// /// Gets the Empty /// public static Percentage Empty { get; } = new Percentage(double.NaN); /// /// Gets a value indicating whether IsEmpty /// public bool IsEmpty => double.IsNaN(this.Percent); /// /// Gets the Normalized /// public double Normalized => this.Percent * 0.01; /// /// Gets the Percent /// public double Percent { get; } /// /// The Equals /// /// The obj /// The public override bool Equals(object obj) { return base.Equals(obj); } /// /// The Equals /// /// The other /// The public bool Equals(Percentage other) { var equals = this.Percent.IsEqualTo(other.Percent); return equals; } /// /// The GetHashCode /// /// The public override int GetHashCode() { return this.Percent.GetHashCode(); } /// /// The ToString /// /// The public override string ToString() { var message = $"{this.Percent.Format()}%"; return message; } public static bool operator ==(Percentage left, Percentage right) { var equals = left.Percent.IsEqualTo(right.Percent); return equals; } public static bool operator !=(Percentage left, Percentage right) { var equals = left.Percent.IsEqualTo(right.Percent); return !equals; } } }