/* 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; using System.Diagnostics; using dnSpy.Contracts.TreeView; namespace dnSpy.Contracts.Documents.TreeView { /// /// Node path name /// public readonly struct NodePathName : IEquatable { /// /// Gets the guid /// public Guid Guid { get; } /// /// Gets the name /// public string Name { get; } /// /// Constructor /// /// Guid of node () /// Extra data if needed or null public NodePathName(Guid guid, string? name = null) { Debug.Assert(guid != System.Guid.Empty); Guid = guid; Name = name ?? string.Empty; } /// /// Equals() /// /// Other instance /// public bool Equals(NodePathName other) => Guid.Equals(other.Guid) && StringComparer.Ordinal.Equals(Name, other.Name); /// /// Equals() /// /// Other instance /// public override bool Equals(object? obj) { if (obj is NodePathName) return Equals((NodePathName)obj); return false; } /// /// GetHashCode() /// /// public override int GetHashCode() => Guid.GetHashCode() ^ StringComparer.Ordinal.GetHashCode(Name ?? string.Empty); /// /// ToString() /// /// public override string ToString() { if (string.IsNullOrEmpty(Name)) return Guid.ToString(); return $"{Guid} - {Name}"; } } }