/*
Copyright (C) 2014-2019 de4dot@gmail.com
This file is part of dnSpy
dnSpy is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
dnSpy is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with dnSpy. If not, see .
*/
using System;
namespace dnSpy.Contracts.Debugger {
///
/// Contains state and localized state that can be shown in the UI
///
public readonly struct DbgStateInfo : IEquatable {
///
/// Non-localized string
///
public string State { get; }
///
/// Localized string (shown in the UI)
///
public string LocalizedState { get; }
///
/// Constructor
///
/// State
public DbgStateInfo(string state)
: this(state, state) {
}
///
/// Constructor
///
/// State (non-localized)
/// Localized state
public DbgStateInfo(string state, string localizedState) {
State = state ?? throw new ArgumentNullException(nameof(state));
LocalizedState = localizedState ?? localizedState ?? throw new ArgumentNullException(nameof(localizedState));
}
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public static bool operator ==(DbgStateInfo left, DbgStateInfo right) => left.Equals(right);
public static bool operator !=(DbgStateInfo left, DbgStateInfo right) => !left.Equals(right);
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
///
/// Equals()
///
///
///
public bool Equals(DbgStateInfo other) => StringComparer.Ordinal.Equals(State, other.State) && StringComparer.Ordinal.Equals(LocalizedState, other.LocalizedState);
///
/// Equals()
///
///
///
public override bool Equals(object? obj) => obj is DbgStateInfo info && Equals(info);
///
/// Gets the hash code
///
///
public override int GetHashCode() => StringComparer.Ordinal.GetHashCode(State ?? string.Empty) ^ StringComparer.Ordinal.GetHashCode(LocalizedState ?? string.Empty);
///
/// Returns
///
///
public override string ToString() => LocalizedState;
}
}